当前位置: 首页>>代码示例>>PHP>>正文


PHP PayPal::addProduct方法代码示例

本文整理汇总了PHP中PayPal::addProduct方法的典型用法代码示例。如果您正苦于以下问题:PHP PayPal::addProduct方法的具体用法?PHP PayPal::addProduct怎么用?PHP PayPal::addProduct使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PayPal的用法示例。


在下文中一共展示了PayPal::addProduct方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: executeRenderPayment

 public function executeRenderPayment()
 {
     $form_id = $this->getParameter('form_id');
     $response = null;
     if ($form_id) {
         $payment_disabled = AB_BookingConfiguration::isPaymentDisabled();
         $this->userData = new AB_UserBookingData($form_id);
         $this->userData->load();
         if ($this->userData->hasData()) {
             if ($this->userData->getServicePrice() <= 0) {
                 $payment_disabled = true;
             }
         }
         if ($payment_disabled == false) {
             $this->form_id = $form_id;
             $this->info_text = nl2br(esc_html(get_option('ab_appearance_text_info_fourth_step')));
             $this->info_text_coupon = $this->_prepareInfoText(4, $this->userData);
             if ($this->userData->hasData()) {
                 $employee = new AB_Staff();
                 $employee->load($this->userData->getStaffId());
                 $service = new AB_Service();
                 $service->load($this->userData->getServiceId());
                 $price = $this->getWpdb()->get_var($this->getWpdb()->prepare('
                     SELECT price FROM ab_staff_service WHERE staff_id = %d AND service_id = %d', $employee->get('id'), $service->get('id')));
                 $this->_prepareProgressTracker(4, $price);
                 // Set response.
                 $response = array('status' => 'success', 'html' => $this->render('payment', array(), false));
             } else {
                 if (isset($_SESSION['tmp_booking_data'])) {
                     $tmp_booking_data = AB_CommonUtils::getTemporaryBookingData();
                     if (!empty($tmp_booking_data)) {
                         $tmp_form_id = $tmp_booking_data['form_id'];
                         if (isset($_SESSION['appointment_booking'][$tmp_form_id]) && $_SESSION['appointment_booking'][$tmp_form_id]['cancelled'] === true) {
                             $employee = new AB_Staff();
                             $employee->load($tmp_booking_data['staff_id'][0]);
                             $service = new AB_Service();
                             $service->load($tmp_booking_data['service_id']);
                             $price = $this->getWpdb()->get_var($this->getWpdb()->prepare('
                             SELECT price FROM ab_staff_service WHERE staff_id = %d AND service_id = %d', $employee->get('id'), $service->get('id')));
                             // create a paypal object
                             $paypal = new PayPal();
                             $product = new stdClass();
                             $product->name = $service->get('title');
                             $product->desc = $service->getTitleWithDuration();
                             $product->price = $price;
                             $product->qty = 1;
                             $paypal->addProduct($product);
                             // get the products information from the $_POST and create the Product objects
                             $this->paypal = $paypal;
                             $this->_prepareProgressTracker(4, $price);
                             $error_msg = isset($_SESSION['appointment_booking'][$tmp_form_id]['paypal_error']) ? $_SESSION['appointment_booking'][$tmp_form_id]['paypal_error'] : "";
                             unset($_SESSION['appointment_booking'][$tmp_form_id]['paypal_error']);
                             // Set response.
                             $response = array('status' => 'success', 'html' => $this->render('payment', array('form_id' => $tmp_form_id, 'error_msg' => $error_msg), false));
                         }
                     }
                 }
             }
         }
     }
     // Output JSON response.
     if ($response === null) {
         $response = array('status' => 'no-data');
     }
     header('Content-Type: application/json');
     echo json_encode($response);
     exit(0);
 }
开发者ID:VLabsInc,项目名称:WordPressPlatforms,代码行数:68,代码来源:AB_BookingController.php

示例2: Form

$objForm = new Form();
$token1 = $objForm->getPost('token');
if ($token2 == Login::string2hash($token1)) {
    // create order
    $objOrder = new Order();
    if ($objOrder->createOrder()) {
        // populate order details
        $order = $objOrder->getOrder();
        $items = $objOrder->getOrderItems();
        if (!empty($order) && !empty($items)) {
            $objBasket = new Basket();
            $objCatalogue = new Catalogue();
            $objPayPal = new PayPal();
            foreach ($items as $item) {
                $product = $objCatalogue->getProduct($item['product']);
                $objPayPal->addProduct($item['product'], $product['name'], $item['price'], $item['qty']);
            }
            $objPayPal->_tax_cart = $objBasket->_vat;
            // populate client's details
            $objUser = new User();
            $user = $objUser->getUser($order['client']);
            if (!empty($user)) {
                // get user country record
                $objCountry = new Country();
                $country = $objCountry->getCountry($user['country']);
                // pass client's details to the PayPal instance
                $objPayPal->_populate = array('address1' => $user['address_1'], 'address2' => $user['address_2'], 'city' => $user['town'], 'state' => $user['county'], 'zip' => $user['post_code'], 'country' => $country['code'], 'email' => $user['email'], 'first_name' => $user['first_name'], 'last_name' => $user['last_name']);
                // redirect client to PayPal
                echo $objPayPal->run($order['id']);
            }
        }
开发者ID:sydorenkovd,项目名称:e-com.loc,代码行数:31,代码来源:paypal.php


注:本文中的PayPal::addProduct方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。