本文整理汇总了PHP中fn_calculate_cart_content函数的典型用法代码示例。如果您正苦于以下问题:PHP fn_calculate_cart_content函数的具体用法?PHP fn_calculate_cart_content怎么用?PHP fn_calculate_cart_content使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了fn_calculate_cart_content函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: array
} else {
return array(CONTROLLER_STATUS_OK, "gift_certificates.add");
}
}
// Gift certificates is empty, create it
if (empty($_SESSION['cart']['gift_certificates'])) {
$_SESSION['cart']['gift_certificates'] = array();
}
$previous_cart_total = isset($_SESSION['cart']['total']) ? floatval($_SESSION['cart']['total']) : 0;
list($gift_cert_id, $gift_cert) = fn_add_gift_certificate_to_cart($gift_cert_data, $auth);
if (!empty($gift_cert_id)) {
$_SESSION['cart']['gift_certificates'][$gift_cert_id] = $gift_cert;
}
fn_save_cart_content($_SESSION['cart'], $auth['user_id']);
if (defined('AJAX_REQUEST')) {
fn_calculate_cart_content($_SESSION['cart'], $auth, false, false, 'F', false);
if ($previous_cart_total == floatval($_SESSION['cart']['total'])) {
fn_delete_cart_gift_certificate($gift_cert_id);
fn_set_notification('N', fn_get_lang_var('notice'), fn_get_lang_var('text_failed_gift_certificate_addition'));
exit;
}
$view->assign('cart_amount', $_SESSION['cart']['amount']);
$view->assign('cart_subtotal', $_SESSION['cart']['subtotal']);
fn_set_notification('N', fn_get_lang_var('notice'), fn_get_lang_var('text_gift_cert_added_to_cart'));
$view->display('views/checkout/components/cart_status.tpl');
exit;
}
}
}
if ($mode == 'update') {
if (!empty($_REQUEST['gift_cert_data']) && !empty($_REQUEST['gift_cert_id']) && $_REQUEST['type'] == 'C') {
开发者ID:diedsmiling,项目名称:busenika,代码行数:31,代码来源:gift_certificates.php
示例2: fn_promotion_validate
/**
* Validate rule
*
* @param int $promotion_id promotion ID
* @param array $promotion rule data
* @param array $data data array
* @param array $auth auth array (for cart rules)
* @param array $cart_products cart products array (for cart rules)
* @return bool true if rule can be applied, false - otherwise
*/
function fn_promotion_validate($promotion_id, $promotion, &$data, &$auth, &$cart_products)
{
$schema = fn_promotion_get_schema('conditions');
$stop_validating = false;
$result = true;
static $parent_orders = array();
fn_set_hook('pre_promotion_validate', $promotion_id, $promotion, $data, $stop_validating, $result, $auth, $cart_products);
if ($stop_validating) {
return $result;
}
if (empty($promotion['condition'])) {
// if promotion is unconditional, apply it
return true;
}
$promotion['value'] = !isset($promotion['value']) ? '' : $promotion['value'];
if (!empty($schema[$promotion['condition']])) {
$value = '';
$parent_order_value = '';
if (!empty($data['parent_order_id']) && empty($parent_orders[$data['parent_order_id']])) {
$parent_orders[$data['parent_order_id']] = array('cart' => array(), 'cart_products' => array(), 'product_groups' => array());
fn_form_cart($data['parent_order_id'], $parent_orders[$data['parent_order_id']]['cart'], $auth);
list($parent_orders[$data['parent_order_id']]['cart_products'], $parent_orders[$data['parent_order_id']]['product_groups']) = fn_calculate_cart_content($parent_orders[$data['parent_order_id']]['cart'], $auth);
}
// Ordinary field
if (!empty($schema[$promotion['condition']]['field'])) {
// Array definition, parse it
if (strpos($schema[$promotion['condition']]['field'], '@') === 0) {
$value = fn_promotion_get_object_value($schema[$promotion['condition']]['field'], $data, $auth, $cart_products);
} else {
// If field can be used in both zones, it means that we're using products
if (in_array('catalog', $schema[$promotion['condition']]['zones']) && in_array('cart', $schema[$promotion['condition']]['zones']) && !empty($cart_products)) {
// this is the "cart" zone. FIXME!!!
foreach ($cart_products as $v) {
if ($promotion['operator'] == 'nin') {
if (fn_promotion_validate_attribute($v[$schema[$promotion['condition']]['field']], $promotion['value'], 'in')) {
return false;
}
} else {
if (fn_promotion_validate_attribute($v[$schema[$promotion['condition']]['field']], $promotion['value'], $promotion['operator'])) {
return true;
}
}
}
return $promotion['operator'] == 'nin' ? true : false;
}
if (!isset($data[$schema[$promotion['condition']]['field']])) {
return false;
}
$value = $data[$schema[$promotion['condition']]['field']];
if (!empty($data['parent_order_id']) && !empty($parent_orders[$data['parent_order_id']]['cart'][$schema[$promotion['condition']]['field']])) {
$parent_order_value = $parent_orders[$data['parent_order_id']]['cart'][$schema[$promotion['condition']]['field']];
}
}
// Field is the result of function
} elseif (!empty($schema[$promotion['condition']]['field_function'])) {
$function_args = $schema[$promotion['condition']]['field_function'];
$function_name = array_shift($function_args);
$function_args_definitions = $function_args;
// If field can be used in both zones, it means that we're using products
if (in_array('catalog', $schema[$promotion['condition']]['zones']) && in_array('cart', $schema[$promotion['condition']]['zones']) && !empty($cart_products)) {
// this is the "cart" zone. FIXME!!!
foreach ($cart_products as $product) {
$function_args = $function_args_definitions;
foreach ($function_args as $k => $v) {
if (strpos($v, '@') !== false) {
$function_args[$k] =& fn_promotion_get_object_value($v, $product, $auth, $cart_products);
} elseif ($v == '#this') {
$function_args[$k] =& $promotion;
} elseif ($v == '#id') {
$function_args[$k] =& $promotion_id;
}
}
$value = call_user_func_array($function_name, $function_args);
if ($promotion['operator'] == 'nin') {
if (fn_promotion_validate_attribute($value, $promotion['value'], 'in')) {
return false;
}
} else {
if (fn_promotion_validate_attribute($value, $promotion['value'], $promotion['operator'])) {
return true;
}
}
}
return $promotion['operator'] == 'nin' ? true : false;
}
foreach ($function_args as $k => $v) {
if (strpos($v, '@') !== false) {
$function_args[$k] =& fn_promotion_get_object_value($v, $data, $auth, $cart_products);
} elseif ($v == '#this') {
$function_args[$k] =& $promotion;
//.........这里部分代码省略.........
开发者ID:askzap,项目名称:ultimate,代码行数:101,代码来源:fn.promotions.php
示例3: apiPlaceOrder
public static function apiPlaceOrder($data, &$response, $lang_code = CART_LANGUAGE)
{
$cart =& $_SESSION['cart'];
$auth =& $_SESSION['auth'];
if (empty($cart)) {
$response->addError('ERROR_ACCESS_DENIED', __('access_denied', $lang_code));
$response->returnResponse();
}
if (!empty($data['user'])) {
fn_twg_api_set_cart_user_data($data['user'], $response, $lang_code);
}
if (empty($auth['user_id']) && empty($cart['user_data'])) {
$response->addError('ERROR_ACCESS_DENIED', __('access_denied', $lang_code));
$response->returnResponse();
}
if (empty($data['payment_info']) && !empty($cart['extra_payment_info'])) {
$data['payment_info'] = $cart['extra_payment_info'];
}
if (!empty($data['payment_info'])) {
$cart['payment_id'] = (int) $data['payment_info']['payment_id'];
unset($data['payment_info']['payment_id']);
if (!empty($data['payment_info'])) {
$cart['payment_info'] = $data['payment_info'];
}
unset($cart['payment_updated']);
fn_update_payment_surcharge($cart, $auth);
fn_save_cart_content($cart, $auth['user_id']);
}
unset($cart['payment_info']['secure_card_number']);
// Remove previous failed order
if (!empty($cart['failed_order_id']) || !empty($cart['processed_order_id'])) {
$_order_ids = !empty($cart['failed_order_id']) ? $cart['failed_order_id'] : $cart['processed_order_id'];
foreach ($_order_ids as $_order_id) {
fn_delete_order($_order_id);
}
$cart['rewrite_order_id'] = $_order_ids;
unset($cart['failed_order_id'], $cart['processed_order_id']);
}
if (!empty($data['shippings'])) {
if (!fn_checkout_update_shipping($cart, $data['shippings'])) {
unset($cart['shipping']);
}
}
Registry::set('runtime.controller', 'checkout', true);
list(, $_SESSION['shipping_rates']) = fn_calculate_cart_content($cart, $auth, 'E');
Registry::set('runtime.controller', 'twigmo');
if (empty($cart['shipping']) && $cart['shipping_failed']) {
$response->addError('ERROR_WRONG_CHECKOUT_DATA', __('wrong_shipping_info', $lang_code));
$response->returnResponse();
}
if (empty($cart['payment_info']) && !isset($cart['payment_id'])) {
$response->addError('ERROR_WRONG_CHECKOUT_DATA', __('wrong_payment_info', $lang_code));
$response->returnResponse();
}
if (!empty($data['notes'])) {
$cart['notes'] = $data['notes'];
}
$cart['details'] = fn_twg_get_twigmo_order_note();
Registry::set('runtime.controller', 'checkout', true);
list($order_id, $process_payment) = fn_place_order($cart, $auth);
Registry::set('runtime.controller', 'twigmo');
if (empty($order_id)) {
return false;
}
if ($process_payment == true) {
$payment_info = !empty($cart['payment_info']) ? $cart['payment_info'] : array();
Registry::set('runtime.mode', 'place_order');
fn_start_payment($order_id, array(), $payment_info);
}
self::orderPlacementRoutines($order_id);
return $order_id;
}
开发者ID:askzap,项目名称:ultimate,代码行数:72,代码来源:TwigmoOrder.php
示例4: die
* This is commercial software, only users who have purchased a valid *
* license and accept to the terms of the License Agreement can install *
* and use this program. *
* *
****************************************************************************
* PLEASE READ THE FULL TEXT OF THE SOFTWARE LICENSE AGREEMENT IN THE *
* "copyright.txt" FILE PROVIDED WITH THIS DISTRIBUTION PACKAGE. *
****************************************************************************/
use Tygh\Registry;
if (!defined('BOOTSTRAP')) {
die('Access denied');
}
if (in_array($mode, array('cart', 'checkout', 'place_order')) && isset(Tygh::$app['session']['cart']['use_gift_certificates'])) {
$company_id = Registry::get('runtime.company_id');
$codes = fn_check_gift_certificate_code(array_keys(Tygh::$app['session']['cart']['use_gift_certificates']), true, $company_id);
$remove_codes = array_diff_key(Tygh::$app['session']['cart']['use_gift_certificates'], !empty($codes) ? $codes : array());
$removed_codes = false;
if (!empty($remove_codes)) {
foreach ($remove_codes as $code => $value) {
unset(Tygh::$app['session']['cart']['use_gift_certificates'][$code]);
}
$removed_codes = true;
}
if ($removed_codes) {
fn_set_notification('W', __('warning'), __('warning_gift_cert_deny', array('[codes]' => implode(', ', array_keys($remove_codes)))), 'K');
}
if ($mode == 'place_order') {
fn_calculate_cart_content(Tygh::$app['session']['cart'], $auth, 'A', true, 'F');
}
return;
}
开发者ID:ambient-lounge,项目名称:site,代码行数:31,代码来源:checkout.pre.php
示例5: fn_twg_api_get_shippings
function fn_twg_api_get_shippings(&$params)
{
list(, $product_groups) = fn_calculate_cart_content($params['cart'], $params['auth']);
$result = array();
$product_groups = $product_groups ? $product_groups : array();
foreach ($product_groups as $group_key => &$product_group) {
$product_group['group_key'] = $group_key;
$is_free_shippings = $product_group['all_edp_free_shipping'] || $product_group['all_free_shipping'] || $product_group['free_shipping'] || $product_group['shipping_no_required'];
if (!$is_free_shippings) {
$result[] = $product_groups[$group_key];
}
}
return $result;
}
开发者ID:arpad9,项目名称:bygmarket,代码行数:14,代码来源:func.php
示例6: fn_checkout_update_steps
//.........这里部分代码省略.........
$user_data = fn_array_merge($current_user_data, $user_data);
$user_data['user_type'] = !empty($current_user_data['user_type']) ? $current_user_data['user_type'] : AREA;
$user_data = fn_fill_contact_info_from_address($user_data);
}
$user_data = fn_array_merge($current_user_data, $user_data);
if (empty($params['ship_to_another'])) {
$profile_fields = fn_get_profile_fields('O');
fn_fill_address($user_data, $profile_fields);
}
// Check if we need to send notification with new email to customer
$email = db_get_field('SELECT email FROM ?:users WHERE user_id = ?i', $auth['user_id']);
$send_notification = false;
if (isset($user_data['email']) && $user_data['email'] != $email) {
$send_notification = true;
}
list($user_id, $profile_id) = fn_update_user($auth['user_id'], $user_data, $auth, !empty($params['ship_to_another']), $send_notification, false);
$cart['profile_id'] = $profile_id;
}
// Add/Update additional fields
if (!empty($user_data['fields'])) {
fn_store_profile_fields($user_data, array('U' => $auth['user_id'], 'P' => $profile_id), 'UP');
// FIXME
}
} elseif (Registry::get('settings.Checkout.disable_anonymous_checkout') != 'Y') {
if (empty($auth['user_id']) && !empty($user_data['email'])) {
$email_exists = fn_is_user_exists(0, $user_data);
if (!empty($email_exists)) {
fn_set_notification('E', __('error'), __('error_user_exists'));
fn_save_post_data('user_data');
if (!empty($params['guest_checkout'])) {
$redirect_params['edit_step'] = $params['step_two'];
$redirect_params['guest_checkout'] = 1;
}
return $redirect_params;
}
}
if (isset($user_data['fields'])) {
$fields = fn_array_merge(isset($cart['user_data']['fields']) ? $cart['user_data']['fields'] : array(), $user_data['fields']);
}
if ($params['update_step'] == 'step_two' && !empty($user_data)) {
$user_data = fn_fill_contact_info_from_address($user_data);
}
$cart['user_data'] = fn_array_merge($cart['user_data'], $user_data);
// Fill shipping info with billing if needed
if (empty($params['ship_to_another']) && $params['update_step'] == 'step_two') {
$profile_fields = fn_get_profile_fields('O');
fn_fill_address($cart['user_data'], $profile_fields);
}
if (!empty($cart['user_data']['b_vat_id']) && !empty($cart['user_data']['b_country'])) {
if (fn_check_vat_id($user_data['b_vat_id'], $cart['user_data']['b_country'])) {
fn_set_notification('N', __('notice'), __('vat_id_number_is_valid'));
} else {
fn_set_notification('E', __('error'), __('vat_id_number_is_not_valid'));
$cart['user_data']['b_vat_id'] = '';
return $redirect_params;
}
} elseif (isset($user_data['b_vat_id'])) {
$user_data['b_vat_id'] = '';
}
}
if (!empty($params['next_step'])) {
$redirect_params['edit_step'] = $params['next_step'];
}
if (!empty($params['shipping_ids'])) {
fn_checkout_update_shipping($cart, $params['shipping_ids']);
}
if (!empty($params['payment_id'])) {
$cart['payment_id'] = (int) $params['payment_id'];
if (!empty($params['payment_info'])) {
$cart['extra_payment_info'] = $params['payment_info'];
if (!empty($cart['extra_payment_info']['card_number'])) {
$cart['extra_payment_info']['secure_card_number'] = preg_replace('/^(.+?)([0-9]{4})$/i', '***-$2', $cart['extra_payment_info']['card_number']);
}
} else {
unset($cart['extra_payment_info']);
}
fn_update_payment_surcharge($cart, $auth);
fn_save_cart_content($cart, $auth['user_id']);
}
if (!empty($params['customer_notes'])) {
$cart['notes'] = $params['customer_notes'];
}
// Recalculate the cart
$cart['recalculate'] = true;
if (!empty($params['next_step']) && ($params['next_step'] == 'step_three' || $params['next_step'] == 'step_four')) {
$cart['calculate_shipping'] = true;
}
$shipping_calculation_type = Registry::get('settings.General.estimate_shipping_cost') == 'Y' || !empty($completed_steps['step_two']) ? 'A' : 'S';
list($cart_products, $product_groups) = fn_calculate_cart_content($cart, $auth, $shipping_calculation_type, true, 'F');
$shipping_hash = fn_get_shipping_hash($cart['product_groups']);
if (!empty($_SESSION['shipping_hash']) && $_SESSION['shipping_hash'] != $shipping_hash && $params['next_step'] == 'step_four' && $cart['shipping_required']) {
if (!empty($cart['chosen_shipping'])) {
fn_set_notification('W', __('important'), __('text_shipping_rates_changed'));
}
$cart['chosen_shipping'] = array();
$redirect_params['edit_step'] = 'step_three';
return $redirect_params;
}
return $redirect_params;
}
开发者ID:heg-arc-ne,项目名称:cscart,代码行数:101,代码来源:fn.cart.php
示例7: update
public function update($id, $params)
{
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;
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)) {
$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'];
}
if (!empty($params['products'])) {
$cart['products'] = $params['products'];
}
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:askzap,项目名称:ultimate,代码行数:66,代码来源:Orders.php
示例8: 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
示例9: fn_prepare_to_place_order
function fn_prepare_to_place_order(&$xml_data, &$cart, &$auth)
{
// Update user info
$bill = $xml_data->getElementByName("buyer-billing-address");
$ship = $xml_data->getElementByName("buyer-shipping-address");
$b_customer_name = $bill->getValueByPath("/contact-name");
$s_customer_name = $ship->getValueByPath("/contact-name");
$phone = $ship->getValueByPath('/phone') != '' ? $ship->getValueByPath('/phone') : $bill->getValueByPath('/phone');
$cart['user_data'] = array('firstname' => substr($s_customer_name, 0, strpos($s_customer_name, ' ')), 'lastname' => substr($s_customer_name, strpos($s_customer_name, ' ')), 'email' => $ship->getValueByPath('/email'), 'phone' => $phone, 'b_firstname' => substr($b_customer_name, 0, strpos($b_customer_name, ' ')), 'b_lastname' => substr($b_customer_name, strpos($b_customer_name, ' ')), 'b_address' => $bill->getValueByPath('/address1'), 'b_address_2' => $bill->getValueByPath('/address2'), 'b_city' => $bill->getValueByPath('/city'), 'b_state' => $bill->getValueByPath('/region'), 'b_country' => $bill->getValueByPath('/country-code'), 'b_zipcode' => $bill->getValueByPath('/postal-code'), 's_firstname' => substr($s_customer_name, 0, strpos($s_customer_name, ' ')), 's_lastname' => substr($s_customer_name, strpos($s_customer_name, ' ')), 's_address' => $ship->getValueByPath('/address1'), 's_address_2' => $ship->getValueByPath('/address2'), 's_city' => $ship->getValueByPath('/city'), 's_state' => $ship->getValueByPath('/region'), 's_country' => $ship->getValueByPath('/country-code'), 's_zipcode' => $ship->getValueByPath('/postal-code'));
// Find whether coupons or gift certificates are used.
fn_get_google_codes($cart, $xml_data);
// Find whether surcharge is used
$itm = $xml_data->getElementByPath('/shopping-cart/items');
$items = $itm->getElementsByName('item');
$total = sizeof($items);
for ($i = 0; $i < $total; $i++) {
if ($items[$i]->getValueByPath('/item-name') == fn_get_lang_var('surcharge')) {
$cart['payment_surcharge'] = $items[$i]->getValueByPath('/unit-price');
}
}
// Update shipping info
$order_adj = $xml_data->getElementByName("order-adjustment");
if ($order_adj->getElementByPath('/shipping/merchant-calculated-shipping-adjustment')) {
$order_shipping = $order_adj->getValueByPath('/shipping/merchant-calculated-shipping-adjustment/shipping-name');
$gc_shippings = $xml_data->getElementByPath('shopping-cart/merchant-private-data/additional_data/shippings');
if ($gc_shippings) {
$gc_methods = $gc_shippings->getElementsByName('method');
$gc_methods_total = sizeof($gc_methods);
for ($k = 0; $k < $gc_methods_total; $k++) {
if ($gc_methods[$k]->getAttribute('name') == $order_shipping) {
$id = $gc_methods[$k]->getAttribute('id');
fn_fill_google_shipping_info($id, $cart, $order_adj, $order_shipping);
break;
}
}
}
}
$cart['recalculate'] = true;
fn_calculate_cart_content($cart, $auth, 'A', true, 'I', true);
$cart['payment_id'] = db_get_field("SELECT a.payment_id FROM ?:payments as a LEFT JOIN ?:payment_processors as b ON a.processor_id = b.processor_id WHERE b.processor_script = 'google_checkout.php'");
list($order_id) = fn_place_order($cart, $auth, 'save');
// This string is here because payment_cc.php file wasn't executed
db_query("REPLACE INTO ?:order_data (order_id, type, data) VALUES (?i, 'S', ?i)", $order_id, TIME);
return $order_id;
}
开发者ID:diedsmiling,项目名称:busenika,代码行数:45,代码来源:google_checkout_response.php
示例10: fn_get_ebay_orders
function fn_get_ebay_orders($cart, $customer_auth)
{
$success_orders = $failed_orders = array();
setlocale(LC_TIME, 'en_US');
$params = array('OrderStatus' => 'All');
$last_transaction = db_get_field('SELECT timestamp FROM ?:ebay_cached_transactions WHERE type = ?s AND status = ?s ORDER BY timestamp DESC', 'orders', 'C');
// Need user_id
if (!empty($last_transaction)) {
$params['CreateTimeFrom'] = gmstrftime("%Y-%m-%dT%H:%M:%S", $last_transaction);
$params['CreateTimeTo'] = gmstrftime("%Y-%m-%dT%H:%M:%S", TIME);
}
$data = array('timestamp' => TIME, 'user_id' => $_SESSION['auth']['user_id'], 'session_id' => Session::getId(), 'status' => 'A', 'type' => 'orders', 'result' => '', 'site_id' => 0);
$transaction_id = db_query('INSERT INTO ?:ebay_cached_transactions ?e', $data);
list(, $ebay_orders) = Ebay::instance()->GetOrders($params);
$data = array('status' => 'C', 'result' => count($ebay_orders));
db_query('UPDATE ?:ebay_cached_transactions SET ?u WHERE transaction_id = ?i', $data, $transaction_id);
if (!empty($ebay_orders)) {
foreach ($ebay_orders as $k => $v) {
$order_status = $v['OrderStatus'] == 'Completed' ? 'P' : 'O';
$cart = array();
fn_clear_cart($cart, true);
$item_transactions = $v['TransactionArray'];
$_cart = $products = array();
if (!is_array($item_transactions)) {
$item_transactions = $item_transactions->Transaction;
}
$i = 1;
foreach ($item_transactions as $item) {
$email = (string) $item->Buyer->Email;
break;
}
$shipping_address = $v['ShippingAddress'];
$customer_name = explode(' ', (string) $shipping_address->Name);
$firstname = array_shift($customer_name);
$lastname = implode(' ', $customer_name);
$_cart = array('user_id' => 0, 'company_id' => Registry::get('runtime.company_id'), 'email' => $email, 'ebay_order_id' => $v['OrderID'], 'timestamp' => strtotime($v['CreatedTime']), 'payment_id' => 0, 'user_data' => array('firstname' => $firstname, 'lastname' => $lastname, 'phone' => (string) $shipping_address->Phone, 'country' => (string) $shipping_address->Country, 's_firstname' => $firstname, 's_lastname' => $lastname, 's_address' => (string) $shipping_address->Street1, 's_city' => (string) $shipping_address->CityName, 's_state' => (string) $shipping_address->StateOrProvince, 's_country' => (string) $shipping_address->Country, 's_phone' => (string) $shipping_address->Phone, 's_zipcode' => (string) $shipping_address->PostalCode, 'b_firstname' => $firstname, 'b_lastname' => $lastname, 'b_address' => (string) $shipping_address->Street1, 'b_city' => (string) $shipping_address->CityName, 'b_state' => (string) $shipping_address->StateOrProvince, 'b_country' => (string) $shipping_address->Country, 'b_phone' => (string) $shipping_address->Phone, 'b_zipcode' => (string) $shipping_address->PostalCode), 'notes' => '', 'payment_info' => array(), 'calculate_shipping' => false, 'shipping_required' => false);
$cart = fn_array_merge($cart, $_cart);
foreach ($item_transactions as $item) {
$_item = (array) $item->Item;
$product_id = db_get_field('SELECT product_id FROM ?:ebay_template_products WHERE ebay_item_id = ?i', $_item['ItemID']);
// Need check company_id
if (!$product_id) {
continue;
}
$product = fn_get_product_data($product_id, $cart['user_data']);
$extra = array('product_options' => array());
$options = db_get_array('SELECT ?:product_options.option_id, ?:product_options_descriptions.option_name, ?:product_option_variants_descriptions.variant_id, ?:product_option_variants_descriptions.variant_name
FROM ?:product_options
JOIN ?:product_option_variants ON ?:product_option_variants.option_id = ?:product_options.option_id
JOIN ?:product_options_descriptions ON ?:product_options_descriptions.option_id = ?:product_options.option_id
JOIN ?:product_option_variants_descriptions ON ?:product_option_variants_descriptions.variant_id = ?:product_option_variants.variant_id
WHERE product_id =?i', $product_id);
if (isset($item->Variation)) {
$variations_xml = (array) $item->Variation->VariationSpecifics;
if (isset($variations_xml['NameValueList']->Name)) {
$variations = (array) $variations_xml['NameValueList'];
} else {
foreach ($variations_xml['NameValueList'] as $variation) {
$variations[] = (array) $variation;
}
}
if (isset($variations)) {
if (isset($variations['Name'])) {
foreach ($options as $option) {
if ($variations['Name'] == $option['option_name'] && $variations['Value'] == $option['variant_name']) {
$extra['product_options'][$option['option_id']] = $option['variant_id'];
}
}
} else {
foreach ($variations as $variation) {
foreach ($options as $option) {
if ($variation['Name'] == $option['option_name'] && $variation['Value'] == $option['variant_name']) {
$extra['product_options'][$option['option_id']] = $option['variant_id'];
}
}
}
}
$variations = array();
}
}
$products[$i] = array('product_id' => $product_id, 'amount' => (int) $item->QuantityPurchased, 'price' => (double) $item->TransactionPrice, 'base_price' => (double) $item->TransactionPrice, 'is_edp' => $product['is_edp'], 'edp_shipping' => $product['edp_shipping'], 'free_shipping' => $product['free_shipping'], 'stored_price' => 'Y', 'company_id' => Registry::get('runtime.company_id'), 'extra' => $extra);
unset($product);
$i += 1;
}
if (empty($products)) {
continue;
}
$cart['products'] = $products;
unset($products);
fn_calculate_cart_content($cart, $customer_auth, 'S', false, 'F', false);
$cart['shipping_failed'] = false;
$cart['company_shipping_failed'] = false;
$cart['shipping_cost'] = $cart['display_shipping_cost'] = (double) $v['ShippingServiceSelected']->ShippingServiceCost;
$cart['total'] = $v['Total'];
$cart['subtotal'] = $v['Subtotal'];
list($order_id, $process_payment) = fn_place_order($cart, $customer_auth);
if (!empty($order_id)) {
fn_change_order_status($order_id, $order_status, false);
$success_orders[] = $order_id;
} else {
//.........这里部分代码省略.........
开发者ID:askzap,项目名称:ultimate,代码行数:101,代码来源:func.php
示例11: list
$shipping_calculation_type = 'A';
list($cart_products, $product_groups) = fn_calculate_cart_content($cart, $auth, $shipping_calculation_type, true, 'F');
$payment_methods = fn_prepare_checkout_payment_methods($cart, $auth);
if (!empty($payment_methods)) {
$first_method = reset($payment_methods);
$first_method = reset($first_method);
$checkout_buttons = fn_get_checkout_payment_buttons($cart, $cart_products, $auth);
if (!empty($checkout_buttons)) {
Registry::get('view')->assign('checkout_buttons', $checkout_buttons, false);
}
} else {
$first_method = false;
}
if ($first_method != false && empty($cart['payment_id']) && floatval($cart['total']) != 0) {
$cart['payment_id'] = $first_method['payment_id'];
list($cart_products, $product_groups) = fn_calculate_cart_content($cart, $auth, $shipping_calculation_type, true, 'F');
}
if (!empty($cart['shipping_failed']) || !empty($cart['company_shipping_failed'])) {
$checkout_style = Registry::get('settings.General.checkout_style');
if (defined('AJAX_REQUEST') && $checkout_style != 'multi_page' || $checkout_style == 'multi_page' && !defined('AJAX_REQUEST')) {
fn_set_notification('W', __('warning'), __('text_no_shipping_methods'));
}
}
$shipping_hash = fn_get_shipping_hash($cart['product_groups']);
if (!empty($_SESSION['shipping_hash']) && $_SESSION['shipping_hash'] != $shipping_hash && $cart['shipping_required']) {
$_SESSION['chosen_shipping'] = array();
}
$_SESSION['shipping_hash'] = $shipping_hash;
fn_gather_additional_products_data($cart_products, array('get_icon' => true, 'get_detailed' => true, 'get_options' => true, 'get_discounts' => false));
if (floatval($cart['total']) == 0) {
$cart['payment_id'] = 0;
开发者ID:ambient-lounge,项目名称:site,代码行数:31,代码来源:onestepcheckout.php
示例12: fn_checkout_update_shipping
$cart =& $_SESSION['cart'];
$auth =& $_SESSION['auth'];
// Update shipping info
if (!empty($_REQUEST['shipping_ids'])) {
fn_checkout_update_shipping($cart, $_REQUEST['shipping_ids']);
}
$payment_methods = fn_twg_get_payment_methods();
if (!empty($payment_methods['payment'])) {
foreach ($payment_methods['payment'] as $k => $v) {
if ($options = fn_twg_get_payment_options($v['payment_id'])) {
$payment_methods['payment'][$k]['options'] = $options;
}
}
$cart['recalculate'] = true;
$cart['calculate_shipping'] = true;
fn_calculate_cart_content($cart, $auth, 'A');
$response->setData(array('payments' => $payment_methods['payment'], 'cart' => fn_twg_api_get_session_cart($cart, $lang_code)));
}
} elseif ($meta['object'] == 'shipping_methods') {
$_SESSION['cart']['calculate_shipping'] = true;
$params = array('cart' => &$_SESSION['cart'], 'auth' => &$_SESSION['auth']);
$product_groups = fn_twg_api_get_shippings($params);
$shipping_methods = Api::getAsList('companies_rates', $product_groups);
$shipping_methods['shipping_failed'] = !empty($_SESSION['cart']['shipping_failed']) ? $_SESSION['cart']['shipping_failed'] : false;
$response->setData($shipping_methods);
} elseif ($meta['object'] == 'product_files') {
$file_url = array('fileUrl' => fn_url("orders.get_file&ekey=" . $_REQUEST['ekey'] . "&file_id=" . $_REQUEST['file_id'] . "&product_id=" . $_REQUEST['product_id'], AREA, 'rel'));
$response->setData($file_url);
} elseif ($meta['object'] == 'errors') {
$response->returnResponse();
} else {
开发者ID:OneataBogdan,项目名称:lead_coriolan,代码行数:31,代码来源:twigmo.php
示例13: elseif
} elseif ($mode == 'get_custom_file' && isset($_REQUEST['cart_id']) && isset($_REQUEST['option_id']) && isset($_REQUEST['file'])) {
if (isset($cart['products'][$_REQUEST['cart_id']]['extra']['custom_files'][$_REQUEST['option_id']][$_REQUEST['file']])) {
$file = $cart['products'][$_REQUEST['cart_id']]['extra']['custom_files'][$_REQUEST['option_id']][$_REQUEST['file']];
fn_get_file($file['path'], $file['name']);
}
} elseif ($mode == 'delete_file' && isset($_REQUEST['cart_id'])) {
if (isset($cart['products'][$_REQUEST['cart_id']]['extra']['custom_files'][$_REQUEST['option_id']][$_REQUEST['file']])) {
// Delete saved custom file
$file = $cart['products'][$_REQUEST['cart_id']]['extra']['custom_files'][$_REQUEST['option_id']][$_REQUEST['file']];
@unlink($file['path']);
@unlink($file['path'] . '_thumb');
unset($cart['products'][$_REQUEST['cart_id']]['extra']['custom_files'][$_REQUEST['option_id']][$_REQUEST['file']]);
}
fn_save_cart_content($cart, $customer_auth['user_id']);
$cart['recalculate'] = true;
if (defined('AJAX_REQUEST')) {
fn_set_notification('N', fn_get_lang_var('notice'), fn_get_lang_var('text_product_file_has_been_deleted'));
if ($action == 'from_status') {
fn_calculate_cart_content($cart, $customer_auth, 'S', true, 'F', true);
$view->assign('force_items_deletion', true);
$view->display('views/checkout/components/cart_status.tpl');
exit;
}
}
return array(CONTROLLER_STATUS_REDIRECT, "order_management.products");
}
if (!empty($profile_fields)) {
$view->assign('profile_fields', $profile_fields);
}
$view->assign('cart', $cart);
$view->assign('customer_auth', $customer_auth);
开发者ID:diedsmiling,项目名称:busenika,代码行数:31,代码来源:order_management.php
示例14: array
$callback_response['Response']['CallbackOrders']['CallbackOrder'] = array();
$calculate_taxes = (string) $xml->OrderCalculationCallbacks->CalculateTaxRates == 'true' ? true : false;
$calculate_promotions = (string) $xml->OrderCalculationCallbacks->CalculatePromotions == 'true' ? true : false;
$calculate_shippings = (string) $xml->OrderCalculationCallbacks->CalculateShippingRates == 'true' ? true : false;
$address_id = (string) $xml->CallbackOrders->CallbackOrder->Address->AddressId;
$callback_response['Response']['CallbackOrders']['CallbackOrder']['Address']['AddressId'] = $address_id;
// Fill the cart address information from the Amazon request
$address_xml = $xml->CallbackOrders->CallbackOrder->Address;
$user_data = array('b_address' => (string) $address_xml->AddressFieldOne, 's_address' => (string) $address_xml->AddressFieldOne, 'b_address2' => (string) $address_xml->AddressFieldTwo, 's_address2' => (string) $address_xml->AddressFieldTwo, 'b_city' => (string) $address_xml->City, 's_city' => (string) $address_xml->City, 'b_state' => (string) $address_xml->State, 's_state' => (string) $address_xml->State, 'b_zipcode' => (string) $address_xml->PostalCode, 's_zipcode' => (string) $address_xml->PostalCode, 'b_country' => (string) $address_xml->CountryCode, 's_country' => (string) $address_xml->CountryCode);
if (strpos($user_data['b_zipcode'], '-') !== false) {
$zip = explode('-', $user_data['b_zipcode']);
$user_data['b_zipcode'] = $user_data['s_zipcode'] = $zip[0];
}
$cart['user_data'] = $user_data;
$cart['calculate_shipping'] = true;
list($cart_products, $_SESSION['shipping_product_groups']) = fn_calculate_cart_content($cart, $auth, 'A', true, 'F', true);
$cart_shippings = array();
foreach ($_SESSION['shipping_product_groups'] as $key_group => $group) {
if (!empty($group['shippings'])) {
foreach ($group['shippings'] as $shipping) {
$shipping_id = $shipping['shipping_id'];
if (empty($cart_shippings[$shipping_id])) {
$cart_shippings[$shipping_id] = $shipping;
$cart_shippings[$shipping_id]['rates'] = array();
}
$cart_shippings[$shipping_id]['rates'][$key_group] = $shipping['rate'];
}
}
}
fn_gather_additional_products_data($cart_products, array('get_icon' => false, 'get_detailed' => false, 'get_options' => true, 'get_discounts' => false));
// Determine the tax calculation type
开发者ID:askzap,项目名称:ultimate,代码行数:31,代码来源:amazon_callback.php
示例15: fn_process_paypal_ipn
function fn_process_paypal_ipn($order_id, $data)
{
$order_info = fn_get_order_info($order_id);
if (!empty($order_info) && !empty($data['txn_id']) && (empty($order_info['payment_info']['txn_i
|
请发表评论