function bitcommerce_user_register(&$pObject) { require_once BITCOMMERCE_PKG_PATH . 'includes/bitcommerce_start_inc.php'; if (is_a($pObject, 'BitUser') && !empty($pObject->mUserId) && !empty($_REQUEST['com_interests'])) { CommerceCustomer::syncBitUser($pObject->mInfo); $newCustomer = new CommerceCustomer($pObject->mUserId); foreach ($_REQUEST['com_interests'] as $intId) { $newCustomer->storeCustomerInterest(array('customers_id' => $pObject->mUserId, 'interests_id' => $intId)); } } }
break; case 'savec2i': // Ajax method if ($gBitCustomer->storeCustomerInterest($_REQUEST)) { print '<div class="success">' . tra('Saved') . '</div>'; } die; break; case 'save': $gBitCustomer->storeInterest($_REQUEST); bit_redirect($_SERVER['SCRIPT_NAME']); break; case 'delete': $gBitCustomer->expungeInterest($_REQUEST['interests_id']); bit_redirect($_SERVER['SCRIPT_NAME']); break; case 'edit': $gBitSmarty->assign('editInterest', $gBitCustomer->getInterest($_REQUEST['interests_id'])); break; } } elseif (!empty($_REQUEST['save_options'])) { $gBitSystem->storeConfig('commerce_register_interests', !empty($_REQUEST['commerce_register_interests']) ? 'y' : NULL); bit_redirect($_SERVER['SCRIPT_NAME']); } elseif (!empty($_REQUEST['uninterested'])) { $gBitSmarty->assign_by_ref('uninterestedCustomers', CommerceCustomer::getUninterestedCustomers()); $mid = 'bitpackage:bitcommerce/admin_uninterested_customers.tpl'; } $gBitSmarty->assign_by_ref('interestsList', $gBitCustomer->getInterests()); print $gBitSmarty->fetch($mid, tra('Customer Interests')); require DIR_FS_ADMIN_INCLUDES . 'footer.php'; require DIR_FS_ADMIN_INCLUDES . 'application_bottom.php';
function list_customers_interests($pCustomersId) { $ret = 'none'; if ($interests = CommerceCustomer::getCustomerInterests($pCustomersId)) { $ret = ''; foreach ($interests as $i) { if ($i['is_interested']) { $ret .= $i['interests_name'] . ','; } } } return $ret; }
<?php // // +----------------------------------------------------------------------+ // | bitcommerce | // +----------------------------------------------------------------------+ // | Copyright (c) 2007 bitcommerce.org | // | | // | http://www.bitcommerce.org | // +----------------------------------------------------------------------+ // | This source file is subject to version 2.0 of the GPL license | // +----------------------------------------------------------------------+ // $Id$ // global $gBitSmarty, $gBitSystem; if ($gBitSystem->getConfig('commerce_register_interests')) { require_once BITCOMMERCE_PKG_PATH . 'classes/CommerceCustomer.php'; $gBitSmarty->assign('comInterests', CommerceCustomer::getInterests()); }
// | This source file is subject to version 2.0 of the GPL license, | // | that is bundled with this package in the file LICENSE, and is | // | available through the world-wide-web at the following url: | // | http://www.zen-cart.com/license/2_0.txt. | // | If you did not receive a copy of the zen-cart license and are unable | // | to obtain it through the world-wide-web, please send a note to | // | license@zen-cart.com so we can mail you a copy immediately. | // +----------------------------------------------------------------------+ if (!$gBitUser->isRegistered()) { $_SESSION['navigation']->set_snapshot(); zen_redirect(FILENAME_LOGIN); } require_once DIR_FS_MODULES . 'require_languages.php'; $breadcrumb->add(NAVBAR_TITLE_1, zen_href_link(FILENAME_ACCOUNT, '', 'SSL')); $breadcrumb->add(NAVBAR_TITLE_2); if ($addresses = CommerceCustomer::getAddressesFromId($_SESSION['customer_id'])) { $gBitSmarty->assign('addresses', $addresses); } $redirectPage = BitBase::getParameter($_REQUEST, 'return_page', FILENAME_ADDRESS_BOOK); // error checking when updating or adding an entry if (isset($_POST['action']) && ($_POST['action'] == 'process' || $_POST['action'] == 'update') || isset($_POST['save_address'])) { if ($gBitCustomer->storeAddress($_REQUEST)) { $messageStack->add_session('addressbook', 'Your address book has been successfully updated.', 'success'); zen_redirect(zen_href_link($redirectPage, '', 'SSL')); } else { $gBitSmarty->assign('addressErrors', $gBitCustomer->mErrors); } } elseif (isset($_REQUEST['delete']) && is_numeric($_REQUEST['delete'])) { if (isset($_REQUEST["confirm"])) { $gBitCustomer->expungeAddress($_REQUEST['delete']); $messageStack->add_session('addressbook', 'The selected address has been successfully removed from your address book.', 'success');
} } } $gBitSmarty->assign_by_ref('fulfillmentFiles', $fulfillmentFiles); } } $gBitSmarty->assign('customerStats', zen_get_customers_stats($order->customer['id'])); if ($order_exists) { if ($paymentModule = $order->getPaymentModule()) { if (method_exists($paymentModule, 'admin_notification')) { $gBitSmarty->assign('notificationBlock', $paymentModule->admin_notification($oID)); } } $gBitSmarty->assign('isForeignCurrency', !empty($order->info['currency']) && $order->info['currency'] != DEFAULT_CURRENCY); $gBitSmarty->assign('orderStatuses', commerce_get_statuses(TRUE)); $gBitSmarty->assign('customersInterests', CommerceCustomer::getCustomerInterests($order->customer['id'])); print '<div class="row">'; print '<div class="col-md-8">' . $gBitSmarty->fetch('bitpackage:bitcommerce/admin_order.tpl') . '</div>'; print '<div class="col-md-4">' . $gBitSmarty->fetch('bitpackage:bitcommerce/admin_order_status_history_inc.tpl') . '</div>'; print '</div>'; // check if order has open gv $gv_check = $gBitDb->query("select `order_id`, `unique_id`\n\t\t\t\t\t\t\tfrom " . TABLE_COUPON_GV_QUEUE . "\n\t\t\t\t\t\t\twhere `order_id` = '" . $_REQUEST['oID'] . "' and `release_flag`='N'"); if ($gv_check->RecordCount() > 0) { $goto_gv = '<a href="' . zen_href_link_admin(FILENAME_GV_QUEUE, 'order=' . $_REQUEST['oID']) . '">' . zen_image_button('button_gift_queue.gif', IMAGE_GIFT_QUEUE) . '</a>'; echo ' <tr><td align="right"><table width="225"><tr>'; echo ' <td align="center">'; echo $goto_gv . ' '; echo ' </td>'; echo ' </tr></table></td></tr>'; } ?>
function amazon_process_order($pAmazonOrderId) { global $gAmazonMWS, $gBitUser, $gCommerceSystem, $gBitCustomer, $currencies, $order; $ret = NULL; $request = new MarketplaceWebServiceOrders_Model_GetOrderRequest(); $request->setSellerId(MERCHANT_ID); // @TODO: set request. Action can be passed as MarketplaceWebServiceOrders_Model_GetOrderRequest // object or array of parameters // Set the list of AmazonOrderIds $orderIds = new MarketplaceWebServiceOrders_Model_OrderIdList(); $orderIds->setId(array($pAmazonOrderId)); $request->setAmazonOrderId($orderIds); $holdUser = $gBitUser; $azUser = new BitPermUser($holdUser->lookupHomepage($gCommerceSystem->getConfig('MODULE_PAYMENT_AMAZONMWS_LOCAL_USERNAME', 'amazonmws'))); $azUser->load(); $gBitUser = $azUser; $gBitCustomer = new CommerceCustomer($gBitUser->mUserId); $gBitCustomer->syncBitUser($gBitUser->mInfo); $_SESSION['customer_id'] = $gBitUser->mUserId; try { $response = $gAmazonMWS->getOrder($request); if ($response->isSetGetOrderResult()) { $getOrderResult = $response->getGetOrderResult(); if ($getOrderResult->isSetOrders()) { $oldCwd = getcwd(); chdir(BITCOMMERCE_PKG_PATH); $azOrderList = $getOrderResult->getOrders(); if ($azOrders = $azOrderList->getOrder()) { require_once BITCOMMERCE_PKG_PATH . 'classes/CommerceOrder.php'; $order = new order(); $order->info = array('order_status' => DEFAULT_ORDERS_STATUS_ID, 'subtotal' => 0, 'tax' => 0, 'total' => 0, 'tax_groups' => array(), 'comments' => isset($_SESSION['comments']) ? $_SESSION['comments'] : '', 'ip_address' => $_SERVER['REMOTE_ADDR']); $azOrder = current($azOrders); // Setup delivery address if ($orderTotal = $azOrder->getOrderTotal()) { $order->info['total'] = $orderTotal->getAmount(); $order->info['currency'] = $orderTotal->getCurrencyCode(); $order->info['currency_value'] = $currencies->currencies[$order->info['currency']]['currency_value']; } if ($shippingAddress = $azOrder->getShippingAddress()) { $country = zen_get_countries(zen_get_country_id($shippingAddress->getCountryCode()), TRUE); $zoneName = zen_get_zone_name_by_code($country['countries_id'], $shippingAddress->getStateOrRegion()); $order->delivery = array('firstname' => substr($shippingAddress->getName(), 0, strpos($shippingAddress->getName(), ' ')), 'lastname' => substr($shippingAddress->getName(), strpos($shippingAddress->getName(), ' ') + 1), 'company' => NULL, 'street_address' => $shippingAddress->getAddressLine1(), 'suburb' => trim($shippingAddress->getAddressLine2() . ' ' . $shippingAddress->getAddressLine3()), 'city' => $shippingAddress->getCity(), 'postcode' => $shippingAddress->getPostalCode(), 'state' => $zoneName, 'country' => $country, 'format_id' => $country['address_format_id'], 'telephone' => $shippingAddress->getPhone(), 'email_address' => NULL); $order->customer = $order->delivery; $order->billing = $order->delivery; } // Setup shipping $shipping = array('cost' => 0); switch ($azOrder->getShipServiceLevel()) { case 'Std US Dom': $shipping['id'] = 'usps_MEDIA'; $shipping['title'] = 'United States Postal Service (USPS Media Mail (1 - 2 Weeks))'; $shipping['code'] = 'USPSREG'; break; } $azOrderItems = amazon_mws_get_order_items($azOrder->getAmazonOrderId()); $azOrderItem = $azOrderItems->getOrderItem(); foreach ($azOrderItem as $azi) { $testSku = $azi->getSellerSKU(); list($productsId, $attrString) = explode(':', $testSku, 2); $productsKey = $productsId . ':ASIN-' . $azi->getASIN(); $order->contents[$productsKey] = $gBitCustomer->mCart->getProductHash($productsKey); $order->contents[$productsKey]['products_quantity'] = $azi->getQuantityOrdered(); $order->contents[$productsKey]['products_name'] = $azi->getTitle(); if ($itemPrice = $azi->getItemPrice()) { // {$itemTax->getCurrencyCode()} $order->contents[$productsKey]['price'] = $itemPrice->getAmount(); $order->contents[$productsKey]['final_price'] = $itemPrice->getAmount(); } if ($itemTax = $azi->getItemTax()) { // {$itemTax->getCurrencyCode()} $order->contents[$productsKey]['tax'] = $itemTax->getAmount(); } if ($shippingPrice = $azi->getShippingPrice()) { // {$itemTax->getCurrencyCode()} $order->info['shipping_cost'] = $shippingPrice->getAmount(); } if (empty($attrString)) { $attrString = $gCommerceSystem->getConfig('MODULE_PAYMENT_AMAZONMWS_DEFAULT_ATTRIBUTES'); } // stock up the attributes if ($attrString && ($attrs = explode(',', $attrString))) { foreach ($attrs as $optionValueId) { $optionId = $order->mDb->getOne("SELECT cpa.`products_options_id` FROM " . TABLE_PRODUCTS_ATTRIBUTES . " cpa WHERE cpa.`products_options_values_id`=?", array($optionValueId)); $order->contents[$productsKey]['attributes'][$optionId . '_' . $optionValueId] = $optionValueId; } } if (!empty($order->contents[$productsKey]['attributes'])) { $attributes = $order->contents[$productsKey]['attributes']; $order->contents[$productsKey]['attributes'] = array(); $subindex = 0; foreach ($attributes as $option => $value) { $optionValues = zen_get_option_value(zen_get_options_id($option), (int) $value); // Determine if attribute is a text attribute and change products array if it is. if ($value == PRODUCTS_OPTIONS_VALUES_TEXT_ID) { $attr_value = $order->contents[$productsKey]['attributes_values'][$option]; } else { $attr_value = $optionValues['products_options_values_name']; } $order->contents[$productsKey]['attributes'][$subindex] = array('option' => $optionValues['products_options_name'], 'value' => $attr_value, 'option_id' => $option, 'value_id' => $value, 'prefix' => $optionValues['price_prefix'], 'price' => $optionValues['options_values_price']); $subindex++; } } $shown_price = zen_add_tax($order->contents[$productsKey]['final_price'], $order->contents[$productsKey]['tax']) * $order->contents[$productsKey]['products_quantity'] + zen_add_tax($order->contents[$productsKey]['onetime_charges'], $order->contents[$productsKey]['tax']); $order->subtotal += $shown_price; $products_tax = $order->contents[$productsKey]['tax']; $products_tax_description = $order->contents[$productsKey]['tax_description']; if (DISPLAY_PRICE_WITH_TAX == 'true') { $order->info['tax'] += $shown_price - $shown_price / ($products_tax < 10 ? "1.0" . str_replace('.', '', $products_tax) : "1." . str_replace('.', '', $products_tax)); if (isset($order->info['tax_groups']["{$products_tax_description}"])) { $order->info['tax_groups']["{$products_tax_description}"] += $shown_price - $shown_price / ($products_tax < 10 ? "1.0" . str_replace('.', '', $products_tax) : "1." . str_replace('.', '', $products_tax)); } else { $order->info['tax_groups']["{$products_tax_description}"] = $shown_price - $shown_price / ($products_tax < 10 ? "1.0" . str_replace('.', '', $products_tax) : "1." . str_replace('.', '', $products_tax)); } } else { $order->info['tax'] += $products_tax / 100 * $shown_price; if (isset($order->info['tax_groups']["{$products_tax_description}"])) { $order->info['tax_groups']["{$products_tax_description}"] += $products_tax / 100 * $shown_price; } else { $order->info['tax_groups']["{$products_tax_description}"] = $products_tax / 100 * $shown_price; } } $order->info['tax'] = zen_round($order->info['tax'], 2); if ($azi->isSetShippingPrice()) { $shippingPrice = $azi->getShippingPrice(); $shipping['cost'] += $shippingPrice->getAmount(); } } foreach (array('cc_type', 'cc_owner', 'cc_number', 'cc_expires', 'coupon_code') as $key) { $order->info[$key] = NULL; } $order->info['shipping_method'] = $shipping['title']; $order->info['shipping_method_code'] = $shipping['code']; $order->info['shipping_module_code'] = $shipping['id']; $order->info['payment_module_code'] = 'amazonmws'; $order->info['payment_method'] = 'Amazon Order'; $_SESSION['sendto'] = NULL; $_SESSION['shipping'] = $shipping; unset($_SESSION['cot_gv']); require_once DIR_FS_CLASSES . 'order_total.php'; global $order_total_modules; $order_total_modules = new order_total(); $order_totals = $order_total_modules->pre_confirmation_check(); require_once DIR_WS_MODULES . 'payment/amazonmws.php'; $amazon = new amazonmws($azOrder->getAmazonOrderId()); $amazonOutput = $amazon->process(); $order_totals = $order_total_modules->process(); array_splice($order_totals, count($order_totals) - 1, 0, array($amazonOutput)); if ($ordersId = $order->create($order_totals, 2)) { $order->create_add_products($ordersId); $ret = $ordersId; $order->updateStatus(array('status' => MODULE_PAYMENT_AMAZONMWS_INITIAL_ORDER_STATUS_ID)); } } chdir($oldCwd); } } } catch (MarketplaceWebServiceOrders_Exception $ex) { echo "Caught Exception: " . $ex->getMessage() . "\n"; echo "Response Status Code: " . $ex->getStatusCode() . "\n"; echo "Error Code: " . $ex->getErrorCode() . "\n"; echo "Error Type: " . $ex->getErrorType() . "\n"; echo "Request ID: " . $ex->getRequestId() . "\n"; echo "XML: " . $ex->getXML() . "\n"; } $gBitUser = $holdUser; $gBitCustomer = new CommerceCustomer($gBitUser->mUserId); $_SESSION['customer_id'] = $gBitUser->mUserId; return $ret; }
// sniffer class require_once DIR_FS_CLASSES . 'sniffer.php'; $sniffer = new sniffer(); if (!empty($_SESSION['customer_id']) && !$gBitUser->isRegistered()) { // we have lost our bitweaver login unset($_SESSION['customer_id']); $customerId = NULL; } elseif ($gBitUser->isRegistered()) { CommerceCustomer::syncBitUser($gBitUser->mInfo); $_SESSION['customer_id'] = $gBitUser->mUserId; $customerId = $gBitUser->mUserId; } else { $customerId = NULL; } global $gBitCustomer, $gCommerceCart; $gBitCustomer = new CommerceCustomer($customerId); $gBitCustomer->load(); $gBitSmarty->assign('gBitCustomer', $gBitCustomer); // lookup information require BITCOMMERCE_PKG_PATH . 'includes/functions/functions_lookups.php'; if (!isset($_SESSION['cc_id'])) { $_SESSION['cc_id'] = NULL; } // include currencies class and create an instance require_once DIR_FS_CLASSES . 'currencies.php'; global $currencies; $currencies = new currencies(); $gBitSmarty->assign('gCommerceCurrencies', $currencies); require_once DIR_FS_CLASSES . 'category_tree.php'; // taxes require_once DIR_FS_FUNCTIONS . 'functions_taxes.php';