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


PHP fn_add_product_to_cart函数代码示例

本文整理汇总了PHP中fn_add_product_to_cart函数的典型用法代码示例。如果您正苦于以下问题:PHP fn_add_product_to_cart函数的具体用法?PHP fn_add_product_to_cart怎么用?PHP fn_add_product_to_cart使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: create

 public function create($params)
 {
     $data = array();
     $valid_params = true;
     $status = Response::STATUS_BAD_REQUEST;
     fn_clear_cart($cart, true);
     if (!empty($params['user_id'])) {
         $cart['user_data'] = fn_get_user_info($params['user_id']);
     } elseif (!empty($params['user_data'])) {
         $cart['user_data'] = $params['user_data'];
     }
     $cart['user_data'] = array_merge($cart['user_data'], $params);
     if (empty($params['user_id']) && empty($params['user_data'])) {
         $data['message'] = __('api_required_field', array('[field]' => 'user_id/user_data'));
         $valid_params = false;
     } elseif (empty($params['payment_id'])) {
         $data['message'] = __('api_required_field', array('[field]' => 'payment_id'));
         $valid_params = false;
     }
     if ($valid_params) {
         $cart['payment_id'] = $params['payment_id'];
         $customer_auth = fn_fill_auth($cart['user_data']);
         fn_add_product_to_cart($params['products'], $cart, $customer_auth);
         fn_calculate_cart_content($cart, $customer_auth);
         if (!empty($cart['product_groups']) && !empty($params['shipping_ids'])) {
             foreach ($cart['product_groups'] as $key => $group) {
                 foreach ($group['shippings'] as $shipping_id => $shipping) {
                     if ($params['shipping_ids'] == $shipping['shipping_id']) {
                         $cart['chosen_shipping'][$key] = $shipping_id;
                         break;
                     }
                 }
             }
         }
         $cart['calculate_shipping'] = true;
         fn_calculate_cart_content($cart, $customer_auth);
         if (empty($cart['shipping_failed']) || empty($params['shipping_ids'])) {
             fn_update_payment_surcharge($cart, $customer_auth);
             list($order_id, ) = fn_place_order($cart, $customer_auth, 'save', $this->auth['user_id']);
             if (!empty($order_id)) {
                 $status = Response::STATUS_CREATED;
                 $data = array('order_id' => $order_id);
             }
         }
     }
     return array('status' => $status, 'data' => $data);
 }
开发者ID:askzap,项目名称:ultimate,代码行数:47,代码来源:Orders.php

示例2: elseif

        } elseif (empty($payment_methods) && !fn_notification_exists('extra', 'no_payment_notification')) {
            fn_set_notification('W', __('notice'), __('cannot_proccess_checkout_without_payment_methods'));
        }
    }
    $ls_shipping_estimation_day = date("d", $ls_shipping_estimation);
    $ls_shipping_estimation_month = date("n", $ls_shipping_estimation);
    $ls_shipping_estimation_year = date("Y", $ls_shipping_estimation);
    $ls_shipping_estimation = date("l F jS, Y", $ls_shipping_estimation);
    $view->assign('ls_shipping_estimation_day', $ls_shipping_estimation_day);
    $view->assign('ls_shipping_estimation_month', $ls_shipping_estimation_month);
    $view->assign('ls_shipping_estimation_year', $ls_shipping_estimation_year);
    $view->assign('ls_shipping_estimation', $ls_shipping_estimation);
    // Step 1/2: Customer information
} elseif ($mode == "add_test") {
    $prev_cart_products = empty($cart['products']) ? array() : $cart['products'];
    fn_add_product_to_cart($_REQUEST['product_data'], $cart, $auth);
    fn_save_cart_content($cart, $auth['user_id']);
    $previous_state = md5(serialize($cart['products']));
    $cart['change_cart_products'] = true;
    fn_calculate_cart_content($cart, $auth, 'S', true, 'F', true);
    if (md5(serialize($cart['products'])) != $previous_state && empty($cart['skip_notification'])) {
        $product_cnt = 0;
        $added_products = array();
        foreach ($cart['products'] as $key => $data) {
            if (empty($prev_cart_products[$key]) || !empty($prev_cart_products[$key]) && $prev_cart_products[$key]['amount'] != $data['amount']) {
                $added_products[$key] = $data;
                $added_products[$key]['product_option_data'] = fn_get_selected_product_options_info($data['product_options']);
                if (!empty($prev_cart_products[$key])) {
                    $added_products[$key]['amount'] = $data['amount'] - $prev_cart_products[$key]['amount'];
                }
                $product_cnt += $added_products[$key]['amount'];
开发者ID:OneataBogdan,项目名称:coriolan_backup,代码行数:31,代码来源:checkout.php

示例3: fn_twg_api_add_product_to_cart

function fn_twg_api_add_product_to_cart($products, &$cart)
{
    $products_data = array();
    foreach ($products as $product) {
        $cid = fn_generate_cart_id($product['product_id'], $product);
        if (!empty($products_data[$cid])) {
            $products_data[$cid]['amount'] += $product['amount'];
        }
        // Get product options images
        $product['combination_hash'] = $cid;
        if (!empty($product['combination_hash']) && !empty($product['product_options'])) {
            $image = fn_get_image_pairs($product['combination_hash'], 'product_option', 'M', true, true, CART_LANGUAGE);
            if (!empty($image)) {
                $product['main_pair'] = $image;
            }
        }
        $products_data[$cid] = $product;
    }
    $auth =& $_SESSION['auth'];
    // actions copied from the checkout.php 'add' action
    $ids = fn_add_product_to_cart($products_data, $cart, $auth);
    fn_save_cart_content($cart, $auth['user_id']);
    $cart['change_cart_products'] = true;
    fn_calculate_cart_content($cart, $auth, 'S', true, 'F', true);
    return $ids;
}
开发者ID:arpad9,项目名称:bygmarket,代码行数:26,代码来源:func.php

示例4: fn_call_requests_placing_order

function fn_call_requests_placing_order($params, $product_data, &$cart, &$auth)
{
    // Save cart
    $buffer_cart = $cart;
    $buffer_auth = $auth;
    $cart = array('products' => array(), 'recalculate' => false, 'payment_id' => 0, 'is_call_request' => true);
    $firstname = $params['name'];
    $lastname = '';
    $cart['user_data']['email'] = $params['email'];
    if (!empty($firstname) && strpos($firstname, ' ')) {
        list($firstname, $lastname) = explode(' ', $firstname);
    }
    $cart['user_data']['firstname'] = $firstname;
    $cart['user_data']['b_firstname'] = $firstname;
    $cart['user_data']['s_firstname'] = $firstname;
    $cart['user_data']['lastname'] = $lastname;
    $cart['user_data']['b_lastname'] = $lastname;
    $cart['user_data']['s_lastname'] = $lastname;
    $cart['user_data']['phone'] = $params['phone'];
    $cart['user_data']['b_phone'] = $params['phone'];
    $cart['user_data']['s_phone'] = $params['phone'];
    foreach (array('b_address', 's_address', 'b_city', 's_city', 'b_country', 's_country', 'b_state', 's_state') as $key) {
        if (!isset($cart['user_data'][$key])) {
            $cart['user_data'][$key] = ' ';
        }
    }
    if (empty($product_data[$params['product_id']])) {
        $product_data[$params['product_id']] = array('product_id' => $params['product_id'], 'amount' => 1);
    }
    fn_add_product_to_cart($product_data, $cart, $auth);
    fn_calculate_cart_content($cart, $auth, 'A', true, 'F', true);
    $order_id = 0;
    if ($res = fn_place_order($cart, $auth)) {
        list($order_id) = $res;
    }
    // Restore cart
    $cart = $buffer_cart;
    $auth = $buffer_auth;
    return $order_id;
}
开发者ID:heg-arc-ne,项目名称:cscart,代码行数:40,代码来源:func.php

示例5: fn_add_product_to_cart

         }
         $_REQUEST['cart_products'][$bb_150['key']]['amount'] = $bb_150['amount'];
         $_REQUEST['cart_products'][$bb_300['key']]['amount'] = $bb_300['amount'];
         $flag_f = false;
         if ($bb_150['amount'] && !$bb_150['key']) {
             $p_data[$exist_bean_bag_150]['product_id'] = $exist_bean_bag_150;
             $p_data[$exist_bean_bag_150]['amount'] = $bb_150['amount'];
             $flag_f = true;
         }
         if ($bb_300['amount'] && !$bb_300['key']) {
             $p_data[$exist_bean_bag_300]['product_id'] = $exist_bean_bag_300;
             $p_data[$exist_bean_bag_300]['amount'] = $bb_300['amount'];
             $flag_f = true;
         }
         if ($flag_f) {
             fn_add_product_to_cart($p_data, $cart, $customer_auth);
             fn_save_cart_content($cart, $customer_auth['user_id']);
         }
     }
     //fn_set_notification('N', 'before', print_r(array($pr_ids,$_REQUEST),true));
     fn_update_cart_by_data($cart, $_REQUEST, $customer_auth);
     if ($combine) {
         foreach ($cart['products'] as $ci => $cv) {
             if (isset($pr_ids[$cv['product_id']])) {
                 $cart['products'][$ci]['amount'] = $pr_ids[$cv['product_id']]['amount'];
             }
         }
     }
     //fn_set_notification('I', 'after', print_r($cart['products'],true));
 }
 if ($mode == 'customer_info') {
开发者ID:ambient-lounge,项目名称:site,代码行数:31,代码来源:order_management.php

示例6: empty

 //                    $product_amount = $product['amount'];
 //                }
 //            }
 //        }
 if ($p_data['bean_bag_filling_150'] == 'Y' && !empty($p_data['bean_bag_quantity_150']) && !empty($exist_bean_bag_150)) {
     $p_data[$exist_bean_bag_150]['product_id'] = $exist_bean_bag_150;
     $p_data[$exist_bean_bag_150]['amount'] = $p_data['bean_bag_quantity_150'] * $pv['amount'];
     //$p_data['bean_bag_quantity_150'];
 }
 if ($p_data['bean_bag_filling_300'] == 'Y' && !empty($p_data['bean_bag_quantity_300']) && !empty($exist_bean_bag_300)) {
     $p_data[$exist_bean_bag_300]['product_id'] = $exist_bean_bag_300;
     $p_data[$exist_bean_bag_300]['amount'] = $p_data['bean_bag_quantity_300'] * $pv['amount'];
     //$product_amount - $bean_bag_300_cart_amount;//$p_data['bean_bag_quantity_300'];
 }
 $prev_cart_products = empty($cart['products']) ? array() : $cart['products'];
 fn_add_product_to_cart($p_data, $cart, $auth);
 fn_save_cart_content($cart, $auth['user_id']);
 $previous_state = md5(serialize($cart['products']));
 $cart['change_cart_products'] = true;
 fn_calculate_cart_content($cart, $auth, 'S', true, 'F', true);
 if (md5(serialize($cart['products'])) != $previous_state && empty($cart['skip_notification'])) {
     $product_cnt = 0;
     //fn_set_notification('N', fn_get_lang_var('notice'), 'different carts');
     $added_products = array();
     foreach ($cart['products'] as $key => $data) {
         if (empty($prev_cart_products[$key]) || !empty($prev_cart_products[$key]) && $prev_cart_products[$key]['amount'] != $data['amount']) {
             $added_products[$key] = $data;
             $added_products[$key]['product_option_data'] = fn_get_selected_product_options_info($data['product_options']);
             if (!empty($prev_cart_products[$key])) {
                 $added_products[$key]['amount'] = $data['amount'] - $prev_cart_products[$key]['amount'];
             }
开发者ID:ambient-lounge,项目名称:site,代码行数:31,代码来源:order_management.post.php

示例7: _fillShoppingCart

 protected function _fillShoppingCart($cartContent)
 {
     if (empty($cartContent['Items'])) {
         return true;
     }
     if (!empty($_SESSION['cart'])) {
         fn_clear_cart($_SESSION['cart']);
     }
     $cart_products = array();
     $cartItems = $cartContent['Items'];
     foreach ($cartItems as $cartItem) {
         $product_id = $cartItem['CartItemId'];
         $item['product_id'] = $product_id;
         $item['amount'] = $cartItem['Count'];
         $cart_products[$product_id] = $item;
     }
     if (!empty($cart_products)) {
         fn_add_product_to_cart($cart_products, $_SESSION['cart'], $_SESSION['auth'], false);
     }
 }
开发者ID:AlekseyChuyan,项目名称:triggmine_cs_cart,代码行数:20,代码来源:integrator.php

示例8: fn_gift_certificates_exclude_products_from_calculation

function fn_gift_certificates_exclude_products_from_calculation(&$cart, &$auth, &$pure_subtotal, &$subtotal)
{
    if (isset($cart['gift_certificates']) && !fn_is_empty($cart['gift_certificates'])) {
        foreach ($cart['gift_certificates'] as $k => $v) {
            if (isset($v['extra']['exclude_from_calculate'])) {
                unset($cart['gift_certificates'][$k]);
            } else {
                $subtotal += $v['amount'];
                $pure_subtotal += $v['amount'];
            }
        }
    }
    if (!empty($cart['use_gift_certificates'])) {
        foreach ($cart['use_gift_certificates'] as $code => $value) {
            // This step is performed when editing the existent order only.
            if (is_array($value) && isset($value['log_id'])) {
                // indicates that the order is being edited
                $gift_cert_data = $value;
                // Merge with the current balance.
                $last_log_item = db_get_row("SELECT log_id, debit, debit_products FROM ?:gift_certificates_log WHERE gift_cert_id = ?i ORDER BY log_id DESC", $value['gift_cert_id']);
                $last_log_item['debit_products'] = unserialize($last_log_item['debit_products']);
                $gift_cert_data['amount'] = $gift_cert_data['previous_state']['cost'] + $last_log_item['debit'];
                if (!empty($last_log_item['debit_products'])) {
                    foreach ($last_log_item['debit_products'] as $product_id => $quantity) {
                        if (!isset($gift_cert_data['products'][$product_id])) {
                            $gift_cert_data['products'][$product_id] = $quantity['amount'];
                        } else {
                            $gift_cert_data['products'][$product_id] = (isset($gift_cert_data['previous_state']['products'][$product_id]) ? $gift_cert_data['previous_state']['products'][$product_id] : 0) + $quantity['amount'];
                        }
                    }
                }
                $cart['use_gift_certificates_previous_state'][$code] = $gift_cert_data;
                // This step is performed when editing the existent order only.
            } elseif (defined('ORDER_MANAGEMENT') && !empty($cart['use_gift_certificates_previous_state'][$code])) {
                //
                // If the certificate was deleted when editing, and then it was applied again.
                // It is necessary to set its data (not currect ones) again with the performed changes.
                //
                $gift_cert_data = $cart['use_gift_certificates_previous_state'][$code];
                // This step is performed only on Create order and in the frontend.
            } else {
                $gift_cert_data = db_get_row("SELECT gift_cert_id, amount, products  FROM ?:gift_certificates WHERE gift_cert_code = ?s ?p", $code, fn_get_gift_certificate_company_condition('company_id'));
                if (!$gift_cert_data) {
                    return false;
                }
                $gift_cert_data['products'] = empty($gift_cert_data['products']) ? array() : @unserialize($gift_cert_data['products']);
                $debit_balance = db_get_row("SELECT debit AS amount, debit_products as products FROM ?:gift_certificates_log WHERE gift_cert_id = ?i ORDER BY log_id DESC", $gift_cert_data['gift_cert_id']);
                if (!empty($debit_balance)) {
                    $debit_balance['products'] = @unserialize($debit_balance['products']);
                    $gift_cert_data = fn_array_merge($gift_cert_data, $debit_balance);
                }
            }
            $cart['use_gift_certificates'][$code] = $gift_cert_data;
            if (!empty($gift_cert_data['products']) && AREA == 'C') {
                $product_data = array();
                foreach ((array) $gift_cert_data['products'] as $key => $product_item) {
                    if (!empty($debit_balance) && !isset($debit_balance['products'][$key])) {
                        continue;
                    }
                    $product_data[$product_item['product_id']] = array('product_id' => $product_item['product_id'], 'amount' => $product_item['amount'], 'extra' => array('exclude_from_calculate' => GIFT_CERTIFICATE_EXCLUDE_PRODUCTS, 'in_use_certificate' => array($code => $product_item['amount'])));
                    if (isset($product_item['product_options'])) {
                        $product_data[$product_item['product_id']]['product_options'] = $product_item['product_options'];
                    }
                    // Сhoose the option which the product had before editing.
                    if (!empty($value['log_id']) && !empty($value['product_options'][$product_id])) {
                        $product_data[$product_id]['product_options'] = $value['product_options'][$product_id];
                    }
                }
                fn_add_product_to_cart($product_data, $cart, $auth);
                $cart['recalculate'] = true;
            }
        }
    }
}
开发者ID:arpad9,项目名称:bygmarket,代码行数:74,代码来源:func.php

示例9: fn_get_aff_banner_data

 if (!empty($_REQUEST['bid'])) {
     $banner = fn_get_aff_banner_data($_REQUEST['bid'], CART_LANGUAGE, true);
     $banner_correct = true;
     if (empty($banner) || $banner['status'] == 'D') {
         return array(CONTROLLER_STATUS_REDIRECT, Registry::get('config.http_location') . '/' . Registry::get('config.customer_index'));
     }
     if (!empty($banner['banner_id']) && !empty($_REQUEST['aff_id'])) {
         $_SESSION['partner_data'] = array('banner_id' => $banner['banner_id'], 'partner_id' => $_REQUEST['aff_id'], 'is_payouts' => 'N', 'product_id' => @$_REQUEST['product_id']);
     }
     if (!empty($banner['type']) && $banner['type'] == 'P') {
         if (!empty($_REQUEST['product_id'])) {
             if (!empty($banner['to_cart']) && $banner['to_cart'] == 'Y') {
                 if (empty($_SESSION['cart'])) {
                     fn_clear_cart($_SESSION['cart']);
                 }
                 fn_add_product_to_cart(array($_REQUEST['product_id'] => array('product_id' => $_REQUEST['product_id'], 'amount' => 1)), $_SESSION['cart'], $auth);
                 $redirect_url = "checkout.cart";
             } else {
                 $redirect_url = "products.view?product_id={$_REQUEST['product_id']}";
             }
         } else {
             $banner_correct = false;
             $banner['type'] = 'T';
             $banner['link_to'] = 'U';
             $banner['url'] = Registry::get('config.http_location');
         }
     }
     if (!empty($banner['link_to']) && $banner['type'] != 'P') {
         $link_to = $banner['link_to'];
         $data =& $banner;
         if ($link_to == 'G' && !empty($banner['group_id'])) {
开发者ID:diedsmiling,项目名称:busenika,代码行数:31,代码来源:aff_banners.php

示例10: fn_clear_cart

if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    // Add product to the cart
    if ($mode == 'add') {
        // Cart is empty, create it
        if (empty($cart)) {
            fn_clear_cart($cart);
        }
        // Remove products with empty amount
        foreach ($_REQUEST['product_data'] as $k => $v) {
            if (empty($v['amount'])) {
                if ($k != 'custom_files') {
                    unset($_REQUEST['product_data'][$k]);
                }
            }
        }
        fn_add_product_to_cart($_REQUEST['product_data'], $_SESSION['cart'], $customer_auth);
        foreach ($cart['products'] as $id => $product) {
            if (!empty($product['extra']['promotions'])) {
                unset($cart['products'][$id]['extra']['promotions']);
            }
        }
        $cart['recalculate_catalog_promotions'] = true;
        fn_calculate_cart_content($cart, $customer_auth);
    }
    // Delete products from the cart
    if ($mode == 'delete') {
        if (!empty($_REQUEST['cart_ids'])) {
            foreach ($_REQUEST['cart_ids'] as $cart_id) {
                fn_delete_cart_product($cart, $cart_id);
            }
        }
开发者ID:OneataBogdan,项目名称:lead_coriolan,代码行数:31,代码来源:order_management.php

示例11: fn_form_cart

function fn_form_cart($order_id, &$cart, &$auth)
{
    $order_info = fn_get_order_info($order_id, false, false);
    // Fill the cart
    foreach ($order_info['items'] as $_id => $item) {
        $_item = array($item['product_id'] => array('amount' => $item['amount'], 'product_options' => @$item['extra']['product_options'], 'price' => $item['original_price'], 'stored_discount' => 'Y', 'stored_price' => 'Y', 'discount' => @$item['extra']['discount'], 'original_amount' => $item['amount'], 'original_product_data' => array('cart_id' => $_id, 'amount' => $item['amount'])));
        if (isset($item['extra'])) {
            $_item[$item['product_id']]['extra'] = $item['extra'];
        }
        fn_add_product_to_cart($_item, $cart, $auth);
    }
    // Restore custom files
    $dir_path = DIR_CUSTOM_FILES . 'order_data/' . $order_id;
    if (is_dir($dir_path)) {
        fn_mkdir(DIR_CUSTOM_FILES . 'sess_data');
        fn_copy($dir_path, DIR_CUSTOM_FILES . 'sess_data');
    }
    $cart['payment_id'] = $order_info['payment_id'];
    $cart['stored_taxes'] = 'Y';
    $cart['stored_discount'] = 'Y';
    $cart['taxes'] = $order_info['taxes'];
    $cart['promotions'] = !empty($order_info['promotions']) ? $order_info['promotions'] : array();
    $cart['shipping'] = !empty($order_info['shipping']) ? $order_info['shipping'] : array();
    $cart['stored_shipping'] = array();
    foreach ($cart['shipping'] as $sh_id => $v) {
        if (!empty($v['rates'])) {
            $cart['stored_shipping'][$sh_id] = array_sum($v['rates']);
        }
    }
    $cart['notes'] = $order_info['notes'];
    $cart['payment_info'] = @$order_info['payment_info'];
    // Add order discount
    if (floatval($order_info['subtotal_discount'])) {
        $cart['stored_subtotal_discount'] = 'Y';
        $cart['subtotal_discount'] = $cart['original_subtotal_discount'] = fn_format_price($order_info['subtotal_discount']);
    }
    // Fill the cart with the coupons
    if (!empty($order_info['coupons'])) {
        $cart['coupons'] = $order_info['coupons'];
    }
    // Set the customer if exists
    $_data = array();
    if (!empty($order_info['user_id'])) {
        $_data = db_get_row("SELECT user_id, user_login as login FROM ?:users WHERE user_id = ?i", $order_info['user_id']);
    }
    $auth = fn_fill_auth($_data, array(), false, 'C');
    $auth['tax_exempt'] = $order_info['tax_exempt'];
    // Fill customer info
    $cart['user_data'] = fn_check_table_fields($order_info, 'user_profiles');
    $cart['user_data'] = fn_array_merge(fn_check_table_fields($order_info, 'users'), $cart['user_data']);
    if (!empty($order_info['fields'])) {
        $cart['user_data']['fields'] = $order_info['fields'];
    }
    fn_add_user_data_descriptions($cart['user_data']);
    fn_set_hook('form_cart', $order_info, $cart);
}
开发者ID:diedsmiling,项目名称:busenika,代码行数:56,代码来源:fn.cart.php

示例12: addProductsToCart

 protected function addProductsToCart($items, $delivery)
 {
     $products = array();
     foreach ($items as $item) {
         $products[$item['offerId']] = array('product_id' => $item['offerId'], 'amount' => $item['count']);
     }
     fn_add_product_to_cart($products, $this->cart, $this->auth);
     $addr = $this->parseDelivery($delivery);
     $this->cart['user_data'] = array('lastname' => self::FAKE_YM_NAME, 'b_firstname' => self::FAKE_YM_NAME, 's_firstname' => self::FAKE_YM_NAME, 'firstname' => self::FAKE_YM_NAME, 'b_lastname' => self::FAKE_YM_NAME, 's_lasttname' => self::FAKE_YM_NAME, 'b_address' => $addr['address'], 's_address' => $addr['address'], 'b_city' => $addr['city'], 's_city' => $addr['city'], 'b_country' => $addr['country_code'], 's_country' => $addr['country_code'], 'b_state' => $_state = !empty($addr['state_code']) ? $addr['state_code'] : $addr['subject_federation'], 's_state' => $_state, 's_zipcode' => $addr['postcode'], 'b_zipcode' => $addr['postcode']);
     if (!empty($delivery['type']) && !empty($delivery['id'])) {
         fn_checkout_update_shipping($this->cart, array(0 => $delivery['id']));
     }
     $this->cart['calculate_shipping'] = true;
     list($cart_products, $product_groups) = fn_calculate_cart_content($this->cart, $this->auth, 'A', true, 'F', true);
     return array($cart_products, $product_groups, $addr);
 }
开发者ID:ambient-lounge,项目名称:site,代码行数:16,代码来源:Purchase.php

示例13: update

 public function update($id, $params)
 {
     if (isset($params['shipping_ids']) && !isset($params['shipping_id'])) {
         $params['shipping_id'] = $params['shipping_ids'];
     }
     fn_define('ORDER_MANAGEMENT', true);
     $data = array();
     $valid_params = true;
     $status = Response::STATUS_BAD_REQUEST;
     if ($valid_params) {
         fn_clear_cart($cart, true);
         $customer_auth = fn_fill_auth(array(), array(), false, 'C');
         $cart_status = md5(serialize($cart));
         // Order info was not found or customer does not have enought permissions
         if (fn_form_cart($id, $cart, $customer_auth) && $cart_status != md5(serialize($cart))) {
             unset($params['product_groups']);
             if (empty($params['shipping_id'])) {
                 $shipping = reset($cart['shipping']);
                 if (!empty($shipping['shipping_id'])) {
                     $params['shipping_id'] = $shipping['shipping_id'];
                 }
             }
             $cart['order_id'] = $id;
             if (!empty($params['products'])) {
                 $product = reset($params['products']);
                 if (isset($product['product_id'], $product['price'])) {
                     $cart['products'] = $params['products'];
                 } else {
                     $cart['products'] = array();
                     fn_add_product_to_cart($params['products'], $cart, $customer_auth);
                 }
             }
             fn_calculate_cart_content($cart, $customer_auth);
             if (!empty($params['user_id'])) {
                 $cart['user_data'] = fn_get_user_info($params['user_id']);
             } elseif (!empty($params['user_data'])) {
                 $cart['user_data'] = $params['user_data'];
             }
             $cart['user_data'] = array_merge($cart['user_data'], $params);
             if (!empty($cart['product_groups']) && !empty($params['shipping_id'])) {
                 foreach ($cart['product_groups'] as $key => $group) {
                     foreach ($group['shippings'] as $shipping_id => $shipping) {
                         if ($params['shipping_id'] == $shipping['shipping_id']) {
                             $cart['chosen_shipping'][$key] = $shipping_id;
                             break;
                         }
                     }
                 }
             }
             if (!empty($params['payment_id'])) {
                 if (!empty($params['payment_info'])) {
                     $cart['payment_info'] = $params['payment_info'];
                 } elseif ($params['payment_id'] != $cart['payment_id']) {
                     $cart['payment_info'] = array();
                 }
                 $cart['payment_id'] = $params['payment_id'];
             }
             fn_calculate_cart_content($cart, $customer_auth);
             if (!empty($cart) && empty($cart['shipping_failed'])) {
                 $cart['parent_order_id'] = 0;
                 fn_update_payment_surcharge($cart, $customer_auth);
                 list($order_id, $order_status) = fn_update_order($cart, $id);
                 if ($order_id) {
                     if (!empty($params['status']) && fn_check_permissions('orders', 'update_status', 'admin')) {
                         fn_change_order_status($order_id, $params['status'], '', fn_get_notification_rules($params, false));
                     } elseif (!empty($order_status)) {
                         fn_change_order_status($order_id, $order_status, '', fn_get_notification_rules($params, false));
                     }
                     $status = Response::STATUS_OK;
                     $data = array('order_id' => $order_id);
                 }
             }
         }
     }
     return array('status' => $status, 'data' => $data);
 }
开发者ID:ambient-lounge,项目名称:site,代码行数:76,代码来源:Orders.php

示例14: define

}
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    if ($mode == 'options') {
        if (!empty($_REQUEST['product_data'])) {
            define('GET_OPTIONS', true);
            // Product data
            unset($_REQUEST['product_data']['custom_files']);
            list($product_id, $_data) = each($_REQUEST['product_data']);
            if (!empty($_data['configuration'])) {
                // Backup cart before changes
                $cart = $_SESSION['cart'];
                $_cart =& $_SESSION['cart'];
                fn_clear_cart($_cart);
                $_data['product_id'] = $product_id;
                $_data['amount'] = isset($_data['amount']) && intval($_data['amount']) <= 0 ? 1 : $_data['amount'];
                fn_add_product_to_cart(array($product_id => $_data), $_cart, $auth);
                list($cart_products) = fn_calculate_cart_content($_cart, $auth, 'S', true, 'F', false);
                if (!empty($_cart['points_info'])) {
                    Registry::set("runtime.product_configurator.points_info.{$product_id}", $_cart['points_info']);
                }
                // Restore cart data
                $_SESSION['cart'] = $cart;
                if (!empty($_REQUEST['appearance'])) {
                    foreach ($_REQUEST['appearance'] as $setting => $value) {
                        $view->assign($setting, $value);
                    }
                    $view->assign('no_images', true);
                }
                $product = reset($cart_products);
                if (!empty($product['amount'])) {
                    $product['selected_amount'] = $product['amount'];
开发者ID:diedsmiling,项目名称:busenika,代码行数:31,代码来源:products.pre.php

示例15: fn_form_cart

function fn_form_cart($order_id, &$cart, &$auth)
{
    $order_info = fn_get_order_info($order_id, false, false);
    if (empty($order_info)) {
        fn_set_notification('E', __('error'), __('object_not_found', array('[object]' => __('order'))), '', '404');
        return false;
    }
    // Fill the cart
    foreach ($order_info['products'] as $_id => $item) {
        $_item = array($item['product_id'] => array('amount' => $item['amount'], 'product_options' => !empty($item['extra']['product_options']) ? $item['extra']['product_options'] : array(), 'price' => $item['original_price'], 'stored_discount' => 'Y', 'stored_price' => 'Y', 'discount' => !empty($item['extra']['discount']) ? $item['extra']['discount'] : 0, 'original_amount' => $item['amount'], 'original_product_data' => array('cart_id' => $_id, 'amount' => $item['amount'])));
        if (isset($item['extra'])) {
            $_item[$item['product_id']]['extra'] = $item['extra'];
        }
        fn_add_product_to_cart($_item, $cart, $auth);
    }
    // Workaround for the add-ons that do not add a product to cart unless the parent product is already added.
    if (count($order_info['products']) > count($cart['products'])) {
        foreach ($order_info['products'] as $_id => $item) {
            if (empty($cart['products'][$_id])) {
                $_item = array($item['product_id'] => array('amount' => $item['amount'], 'product_options' => !empty($item['extra']['product_options']) ? $item['extra']['product_options'] : array(), 'price' => $item['original_price'], 'stored_discount' => 'Y', 'stored_price' => 'Y', 'discount' => !empty($item['extra']['discount']) ? $item['extra']['discount'] : 0, 'original_amount' => $item['amount'], 'original_product_data' => array('cart_id' => $_id, 'amount' => $item['amount'])));
                if (isset($item['extra'])) {
                    $_item[$item['product_id']]['extra'] = $item['extra'];
                }
                fn_add_product_to_cart($_item, $cart, $auth);
            }
        }
    }
    // Restore custom files
    $dir_path = 'order_data/' . $order_id;
    if (Storage::instance('custom_files')->isExist($dir_path)) {
        Storage::instance('custom_files')->copy($dir_path, 'sess_data');
    }
    $cart['payment_id'] = $order_info['payment_id'];
    $cart['stored_taxes'] = 'Y';
    $cart['stored_discount'] = 'Y';
    $cart['taxes'] = $order_info['taxes'];
    $cart['promotions'] = !empty($order_info['promotions']) ? $order_info['promotions'] : array();
    $cart['shipping'] = !empty($order_info['shipping']) ? $order_info['shipping'] : array();
    $cart['stored_shipping'] = array();
    foreach ($cart['shipping'] as $sh_id => $v) {
        if (!empty($v['rates'])) {
            $cart['stored_shipping'][$sh_id] = array_sum($v['rates']);
        }
    }
    if (!empty($order_info['product_groups'])) {
        $cart['product_groups'] = $order_info['product_groups'];
        foreach ($order_info['product_groups'] as $group) {
            if (!empty($group['chosen_shippings'])) {
                foreach ($group['chosen_shippings'] as $key => $chosen_shipping) {
                    foreach ($group['shippings'] as $shipping_id => $shipping) {
                        if ($shipping_id == $chosen_shipping['shipping_id']) {
                            $cart['chosen_shipping'][$chosen_shipping['group_key']] = $shipping_id;
                        }
                    }
                }
            }
        }
    } else {
        $cart['product_groups'] = array();
    }
    $cart['order_timestamp'] = $order_info['timestamp'];
    $cart['notes'] = $order_info['notes'];
    $cart['details'] = $order_info['details'];
    $cart['payment_info'] = @$order_info['payment_info'];
    $cart['profile_id'] = $order_info['profile_id'];
    // Add order discount
    if (floatval($order_info['subtotal_discount'])) {
        $cart['stored_subtotal_discount'] = 'Y';
        $cart['subtotal_discount'] = $cart['original_subtotal_discount'] = fn_format_price($order_info['subtotal_discount']);
    }
    // Fill the cart with the coupons
    if (!empty($order_info['coupons'])) {
        $cart['coupons'] = $order_info['coupons'];
    }
    // Set the customer if exists
    $_data = array();
    if (!empty($order_info['user_id'])) {
        $_data = db_get_row("SELECT user_id, user_login as login FROM ?:users WHERE user_id = ?i", $order_info['user_id']);
    }
    $auth = fn_fill_auth($_data, array(), false, 'C');
    $auth['tax_exempt'] = $order_info['tax_exempt'];
    // Fill customer info
    $cart['user_data'] = fn_array_merge(fn_check_table_fields($order_info, 'users'), fn_check_table_fields($order_info, 'user_profiles'));
    if (!empty($order_info['fields'])) {
        $cart['user_data']['fields'] = $order_info['fields'];
    }
    fn_add_user_data_descriptions($cart['user_data']);
    fn_set_hook('form_cart', $order_info, $cart, $auth);
    return true;
}
开发者ID:heg-arc-ne,项目名称:cscart,代码行数:90,代码来源:fn.cart.php


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