/** * @see FrontController::initContent() */ public function initContent() { parent::initContent(); $id_cart = Tools::GetValue('id_cart'); $cart = new Cart((int) $id_cart); $liqpay = new Liqpay(); $total = $cart->getOrderTotal(true, 3); $liqpay->validateOrder(intval($cart->id), Configuration::get('PS_OS_PREPARATION'), $total, $liqpay->displayName); $currency = new Currency((int) $cart->id_currency); $private_key = Configuration::get('LIQPAY_PRIVATE_KEY'); $public_key = Configuration::get('LIQPAY_PUBLIC_KEY'); $amount = number_format($cart->getOrderTotal(true, Cart::BOTH), 1, '.', ''); $currency = $currency->iso_code == 'RUR' ? 'RUB' : $currency->iso_code; $order_id = '000' . $id_cart; $description = 'Order #' . $order_id; $result_url = 'http://' . htmlspecialchars($_SERVER['HTTP_HOST'], ENT_COMPAT, 'UTF-8') . __PS_BASE_URI__ . 'index.php?controller=history'; $server_url = 'http://' . htmlspecialchars($_SERVER['HTTP_HOST'], ENT_COMPAT, 'UTF-8') . $liqpay->getPath() . 'validation.php'; $type = 'buy'; $version = '3'; $language = Configuration::get('PS_LOCALE_LANGUAGE') == 'en' ? 'en' : 'ru'; $data = base64_encode(json_encode(array('version' => $version, 'public_key' => $public_key, 'amount' => $amount, 'currency' => $currency, 'description' => $description, 'order_id' => $order_id, 'type' => $type, 'language' => $language))); $signature = base64_encode(sha1($private_key . $data . $private_key, 1)); $this->context->smarty->assign(compact('data', 'signature')); $this->setTemplate('redirect.tpl'); }
/** * @param Request $request * @return string * @throws Exception */ public function showCartAction(Request $request) { $cart = new Cart(); $productsId = $cart->getProducts(); $args = array('productsId' => $productsId); return $this->render('cart', $args); }
public function initContent() { parent::initContent(); $params = KwixoURLCallFrontController::ManageUrlCall(); $payment_ok = $params['payment_status']; $errors = $params['errors']; $id_order = $params['id_order']; if ($id_order != false) { $order = new Order($id_order); $cart = new Cart($order->id_cart); $products = $cart->getProducts(); $amount = $order->total_paid_tax_incl; $total_shipping = $order->total_shipping; } else { $products = false; $amount = false; $total_shipping = false; } $link = new Link(); $this->context->smarty->assign('payment_ok', $payment_ok); $this->context->smarty->assign('errors', $errors); $this->context->smarty->assign('amount', $amount); $this->context->smarty->assign('total_shipping', $total_shipping); $this->context->smarty->assign('products', $products); $this->context->smarty->assign('path_order', $link->getPageLink('order', true)); $this->context->smarty->assign('path_history', $link->getPageLink('history', true)); $this->context->smarty->assign('path_contact', $link->getPageLink('contact', true)); $this->setTemplate('urlcall.tpl'); }
public function login() { $conn = Db::connect(); $sql = 'SELECT user_id FROM users ' . ' WHERE email = ? AND password = ?'; $email = $conn->real_escape_string($_POST['email']); $password = md5($_POST['password']); $statement = $conn->prepare($sql); $statement->bind_param('ss', $email, $password); $statement->execute(); $statement->bind_result($userId); $statement->fetch(); if ($userId == NULL) { return false; } else { session_start(); $_SESSION['user_id'] = $userId; if (isset($_SESSION['cart']) && $_SESSION['cart'] != []) { require_once '../app/models/Cart.php'; $cart = new Cart(); foreach ($_SESSION['cart'] as $product_id => $value) { $cart->addProductToCart($product_id, $_SESSION['cart'][$product_id]['cart_quantity']); } } return true; } }
public static function updateProductsTax(AvalaraTax $avalaraModule, Cart $cart, $id_address, $region, $taxable = true) { $p = array(); foreach ($cart->getProducts() as $product) { $avalaraProducts = array('id_product' => (int) $product['id_product'], 'name' => $product['name'], 'description_short' => $product['description_short'], 'quantity' => 1, 'total' => (double) 1000000, 'tax_code' => $taxable ? $avalaraModule->getProductTaxCode((int) $product['id_product']) : 'NT'); $p[] = $avalaraProducts; // Call Avalara $getTaxResult = $avalaraModule->getTax(array($avalaraProducts), array('type' => 'SalesOrder', 'DocCode' => 1, 'taxable' => $taxable)); // Store the taxrate in cache // If taxrate exists (but it's outdated), then update, else insert (REPLACE INTO) if (isset($getTaxResult['TotalTax']) && isset($getTaxResult['TotalAmount'])) { $total_tax = $getTaxResult['TotalTax']; $total_amount = $getTaxResult['TotalAmount']; if ($total_amount == 0) { $db_rate = 0; } else { $db_rate = (double) ($total_tax * 100 / $total_amount); } Db::getInstance()->Execute('REPLACE INTO `' . _DB_PREFIX_ . 'avalara_product_cache` (`id_product`, `tax_rate`, `region`, `update_date`, `id_address`) VALUES (' . (int) $product['id_product'] . ', ' . $db_rate . ', \'' . ($region ? pSQL($region) : '') . '\', \'' . date('Y-m-d H:i:s') . '\', ' . (int) $cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')} . ')'); } } return $p; }
public function postProcess() { $sid = Configuration::get('TWOCHECKOUTPP_SID'); $secret_word = Configuration::get('TWOCHECKOUTPP_SECRET'); $credit_card_processed = $_REQUEST['credit_card_processed']; $order_number = $_REQUEST['order_number']; $cart_id = $_REQUEST['merchant_order_id']; $cart = new Cart($cart_id); $checkout = new twocheckoutpp(); if (Configuration::get('TWOCHECKOUTPP_CURRENCY') > 0) { $amount = number_format($cart->getOrderTotal(true, 3), 2, '.', ''); $currency_from = Currency::getCurrency($cart->id_currency); $currency_to = Currency::getCurrency(Configuration::get('TWOCHECKOUTPP_CURRENCY')); $amount = Tools::ps_round($amount / $currency_from['conversion_rate'], 2); $total = number_format(Tools::ps_round($amount *= $currency_to['conversion_rate'], 2), 2, '.', ''); } else { $total = number_format($cart->getOrderTotal(true, 3), 2, '.', ''); } //Check the hash $compare_string = $secret_word . $sid . $order_number . $total; $compare_hash1 = strtoupper(md5($compare_string)); $compare_hash2 = $_REQUEST['key']; if ($compare_hash1 == $compare_hash2) { $customer = new Customer($cart->id_customer); $total = (double) $cart->getOrderTotal(true, Cart::BOTH); $checkout->validateOrder($cart_id, _PS_OS_PAYMENT_, $total, $checkout->displayName, '', array(), NULL, false, $customer->secure_key); $order = new Order($checkout->currentOrder); Tools::redirect('index.php?controller=order-confirmation&id_cart=' . (int) $cart->id . '&id_module=' . (int) $this->module->id . '&id_order=' . $checkout->currentOrder); } else { echo 'Hash Mismatch! Please contact the seller directly for assistance.</br>'; echo 'Total: ' . $total . '</br>'; echo '2CO Total: ' . $_REQUEST['total']; } }
/** * @see FrontController::postProcess() */ public function postProcess() { parse_str($_POST['optData'], $optData); $id_cart = (int) $optData['cartId']; $cart = new Cart($id_cart); if ($cart->id_customer == 0 || $cart->id_address_delivery == 0 || $cart->id_address_invoice == 0 || !$this->module->active) { die('Cannot create order for this cart.'); } $customer = new Customer($cart->id_customer); if (!Validate::isLoadedObject($customer)) { die('No customer for this order.'); } $currency = new Currency((int) $cart->id_currency); $paid_amount = $_POST['amount']; $order_amount = $cart->getOrderTotal(true, Cart::BOTH); $apiHash = $_SERVER['HTTP_API_HASH']; $query = http_build_query($_POST); $hash = hash_hmac("sha512", $query, $this->module->secret_key); if ($apiHash == $hash && $paid_amount == $order_amount) { //success $this->module->validateOrder($cart->id, Configuration::get('PS_OS_PAYMENT'), $paid_amount, $this->module->displayName, 'Invoice Code: ' . $_POST['invoiceCode'], array(), (int) $currency->id, false, $customer->secure_key); } else { //failed transaction } }
function testGetDefaultCardHandler() { $cart = new Cart(1, $h = null); $h = $cart->getCartHandler(); $this->assertIsA($h, CART_DEFAULT_HANDLER_TYPE . 'CartHandler'); $this->assertEqual($h->getCartId(), 1); }
public function create(User $user) { $cart = new Cart(); if (isset($_SESSION['id'])) { $set = $cart->setUser($user); if ($set === true) { $set = $cart->setStatus(1); if ($set === true) { $idUser = intval($cart->getUser()->getId()); $status = intval($cart->getStatus()); $query = "INSERT INTO cart (id_user, status) VALUES (" . $idUser . ", " . $status . ")"; $result = $this->database->exec($query); if ($result) { $id = $this->database->lastInsertId(); if ($id) { return $this->findById($id); } else { throw new Exception("Catastrophe serveur."); } } else { throw new Exception("Catastrophe base de données."); } } else { throw new Exception($set); } } else { throw new Exception($set); } } else { $_SESSION['cartStatus'] = 1; } }
/** * Do whatever you have to before redirecting the customer on the website of your payment processor. */ public function postProcess() { /** * Oops, an error occured. */ if (Tools::getValue('action') == 'error') { return $this->displayError('An error occurred while trying to redirect the customer'); } else { //First solution to know if refreshed page: http://stackoverflow.com/a/6127748 $refreshButtonPressed = isset($_SERVER['HTTP_CACHE_CONTROL']) && $_SERVER['HTTP_CACHE_CONTROL'] === 'max-age=0'; $result = $this->module->callToRest('GET', '/orders?mid=' . Context::getContext()->cart->id, null, false); $result['response'] = json_decode($result['response'], true); if ($result['code'] == '200' && isset($result['response']['results'][0]['id']) && !$refreshButtonPressed) { //The cart exists on Aplazame, we try to send with another ID $oldCart = new Cart(Context::getContext()->cart->id); $data = $oldCart->duplicate(); if ($data['success']) { $cart = $data['cart']; Context::getContext()->cart = $cart; CartRule::autoAddToCart(Context::getContext()); Context::getContext()->cookie->id_cart = $cart->id; } else { $this->module->logError('Error: Cannot duplicate cart ' . Context::getContext()->cart->id); } } $this->context->smarty->assign(array('cart_id' => Context::getContext()->cart->id, 'secure_key' => Context::getContext()->customer->secure_key, 'aplazame_order_json' => json_encode($this->module->getCheckoutSerializer(0, Context::getContext()->cart->id), 128), 'aplazame_version' => ConfigurationCore::get('APLAZAME_API_VERSION', null), 'aplazame_url' => Configuration::get('APLAZAME_API_URL', null), 'aplazame_mode' => Configuration::get('APLAZAME_LIVE_MODE', null) ? 'false' : 'true')); return $this->setTemplate('redirect.tpl'); } }
/** * Returns cart items in a format useful for the * API request * * Also adds discount as a cart item, since this is * how Paypal expects to receive discounts * * @param Cart $cart * @return array */ private function getItemsFromCart(Cart $cart) { $items = array(); foreach($cart->getProducts() as $product) { $item = new stdClass(); $item->name = $product->title; $item->number = $product->sku; $item->description = substr($product->short_description, 0, 127); $item->amount = ShopDisplay::numberFormat($product->price); $item->quantity = $product->quantity; $items[] = $item; } if($cart->getDiscountAmount() > 0) { $item = new stdClass(); $item->name = 'Discount'; $item->description = $cart->getDiscountName(); $item->amount = -1 * $cart->getDiscountAmount(); $item->quantity = 1; $items[] = $item; } return $items; }
function textRecord(Product $product, Cart $cart) { global $errors; if (!($fieldIds = $product->getCustomizationFieldIds())) { return false; } $authorizedTextFields = array(); foreach ($fieldIds as $fieldId) { if ($fieldId['type'] == _CUSTOMIZE_TEXTFIELD_) { $authorizedTextFields[intval($fieldId['id_customization_field'])] = 'textField' . intval($fieldId['id_customization_field']); } } $indexes = array_flip($authorizedTextFields); foreach ($_POST as $fieldName => $value) { if (in_array($fieldName, $authorizedTextFields) and !empty($value)) { if (!Validate::isMessage($value)) { $errors[] = Tools::displayError('Invalid message'); } else { $cart->addTextFieldToProduct(intval($product->id), $indexes[$fieldName], $value); } } elseif (in_array($fieldName, $authorizedTextFields) and empty($value)) { $cart->deleteTextFieldFromProduct(intval($product->id), $indexes[$fieldName]); } } }
public function initContent() { $payu = new PayU(); $id_cart = Tools::getValue('id_cart'); $id_payu_session = $this->context->cookie->__get('payu_order_id'); if (Tools::getValue('error')) { Tools::redirect('order.php?error=' . Tools::getValue('error'), __PS_BASE_URI__, null, 'HTTP/1.1 301 Moved Permanently'); } $payu->id_cart = $id_cart; $payu->payu_order_id = $id_payu_session; $order_payment = $payu->getOrderPaymentBySessionId($payu->payu_order_id); $id_order = (int) $order_payment['id_order']; $payu->id_cart = (int) $order_payment['id_cart']; // if order not validated yet $cart_id = $payu->id_cart; if ($id_order == 0 && $order_payment['status'] == PayU::PAYMENT_STATUS_NEW) { $cart = new Cart($payu->id_cart); $cart_id = $cart->id; $payu->validateOrder($cart->id, (int) Configuration::get('PAYU_PAYMENT_STATUS_PENDING'), $cart->getOrderTotal(true, Cart::BOTH), $payu->displayName, 'PayU cart ID: ' . $cart_id . ', sessionId: ' . $payu->payu_order_id, null, (int) $cart->id_currency, false, $cart->secure_key, Context::getContext()->shop->id ? new Shop((int) Context::getContext()->shop->id) : null); $payu->id_order = $payu->current_order = $payu->{'currentOrder'}; $payu->updateOrderPaymentStatusBySessionId(PayU::PAYMENT_STATUS_INIT); } $id_order = $payu->getOrderIdBySessionId($id_payu_session); if (!empty($id_order)) { $payu->id_order = $id_order; $payu->updateOrderData(); } Tools::redirect('index.php?controller=order-confirmation&id_cart=' . $cart_id, __PS_BASE_URI__, null, 'HTTP/1.1 301 Moved Permanently'); }
protected function onGetSimple(array $options) { $cart = new Cart($this->ctx); $result = $cart->getXML(); $result .= $cart->getConfigXML(); return html::wrap('cart', $result, array('mode' => 'simple')); }
public function testCreateInitPayment() { $cart = new Cart(new Currency(Currency::CZK)); $cart->addItem('Nákup na vasobchodcz', 1, 1789600, 'Lenovo ThinkPad Edge E540'); $cart->addItem('Poštovné', 1, 0, 'Doprava PPL'); $request = $this->requestFactory->createInitPayment('5547', new PayOperation(PayOperation::PAYMENT), new PayMethod(PayMethod::CARD), true, 'https://vasobchod.cz/gateway-return', new HttpMethod(HttpMethod::POST), $cart, 'Nákup na vasobchod.cz (Lenovo ThinkPad Edge E540, Doprava PPL)', 'some-base64-encoded-merchant-data', '123', new Language(Language::CZ), 1800, 1, 1); $this->assertInstanceOf(InitPaymentRequest::class, $request); }
function get_cart() { $this->doNotRenderHeader = 1; $m = new Cart(); $data = $m->getCartInfo(); $this->assign('message', $data); $this->setReturnType('message'); }
public function initContent() { parent::initContent(); $log_on = Configuration::get('YA_ORG_LOGGING_ON'); if (Tools::getValue('label')) { $data = explode('_', Tools::getValue('label')); } else { $data = explode('_', Tools::getValue('customerNumber')); } if (!empty($data) && isset($data[1])) { $ordernumber = $data['1']; $this->context->smarty->assign('ordernumber', $ordernumber); $this->context->smarty->assign('time', date('Y-m-d H:i:s ')); if (!$ordernumber) { if ($log_on) { $this->module->logSave('yakassa_success: Error ' . $this->module->l('Cart number is not specified')); } $this->setTemplate('error.tpl'); } else { $cart = new Cart((int) $ordernumber); $qty = $cart->nbProducts(); $this->context->smarty->assign('nbProducts', $qty); if (!Validate::isLoadedObject($cart) || $qty < 1) { if ($log_on) { $this->module->logSave('yakassa_success: Error ' . $this->module->l('Shopping cart does not exist')); } $this->setTemplate('error.tpl'); } else { $ordernumber = (int) $cart->id; if (!$ordernumber) { if ($log_on) { $this->module->logSave('yakassa_success: Error ' . $this->module->l('Order number is not specified')); } $this->setTemplate('error.tpl'); } else { $order = new Order((int) Order::getOrderByCartId($cart->id)); $customer = new Customer((int) $order->id_customer); if ($order->hasBeenPaid()) { if ($log_on) { $this->module->logSave('yakassa_success: #' . $order->id . ' ' . $this->module->l('Order paid')); } Tools::redirectLink(__PS_BASE_URI__ . 'order-confirmation.php?key=' . $customer->secure_key . '&id_cart=' . (int) $order->id_cart . '&id_module=' . (int) $this->module->id . '&id_order=' . (int) $order->id); } else { if ($log_on) { $this->module->logSave('yakassa_success: #' . $order->id . ' ' . $this->module->l('Order wait payment')); } $this->setTemplate('waitingPayment.tpl'); } } } } } else { if ($log_on) { $this->module->logSave('yakassa_success: Error ' . $this->module->l('Cart number is not specified')); } $this->setTemplate('error.tpl'); } }
/** * @param $order_payment * @param $payu * @param $response * @return mixed */ private function createOrder($order_payment, Payu $payu, $response) { $cart = new Cart($order_payment['id_cart']); $payu->validateOrder($cart->id, (int) Configuration::get('PAYU_PAYMENT_STATUS_PENDING'), $cart->getOrderTotal(true, Cart::BOTH), $payu->displayName, 'PayU cart ID: ' . $cart->id . ', orderId: ' . $payu->payu_order_id, null, (int) $cart->id_currency, false, $cart->secure_key, Context::getContext()->shop->id ? new Shop((int) Context::getContext()->shop->id) : null); $id_order = $payu->current_order = $payu->currentOrder; SimplePayuLogger::addLog('notification', __FUNCTION__, 'Status zamówienia PayU: ' . PayU::PAYMENT_STATUS_NEW, $response->order->orderId); $payu->updateOrderPaymentStatusBySessionId(PayU::PAYMENT_STATUS_INIT); return $id_order; }
public function delete() { if (parent::delete()) { $cart = new Cart($this->id_cart); $cart->status = Cart::IS_CLOSE; return $cart->update(); } return false; }
function add_items_to_cart($id, $count) { if (empty($_SESSION['simple_cart']) || !isset($_SESSION['simple_cart'])) { $c = new Cart(); $c->add_item($id, $count); $_SESSION['simple_cart'] = $c; } else { $_SESSION['simple_cart']->add_item($id, $count); } }
public function createFromCart(Cart $cart) { // but big order need customer or something else?? Pdb::insert(array('id=id' => null), self::$table); $id = Pdb::lastInsertId(); foreach ($cart->orders() as $order) { Pdb::insert(array('big' => $id, 'small' => $order->id), 'big_to_small_order'); $order->submit(); } }
public function initContent() { parent::initContent(); if (Tools::getValue('id_cart')) { $cart = new Cart((int) Tools::getValue('id_cart')); $this->context->smarty->assign(array('total' => Tools::displayPrice($cart->getOrderTotal()))); return $this->setTemplate('confirmation.tpl'); } else { return $this->setTemplate('error.tpl'); } }
function renderLayout($layout, $view, $data = null) { $pageInfo = $data['pageInfo']; if (isset($_SESSION['usn'])) { $pageInfo['usn'] = $_SESSION['usn']; require_once "./protected/models/cart.class.php"; $cart = new Cart(array("ownerId" => $_SESSION['usid'])); $pageInfo['cartnum'] = $cart->countNum(array('ownerId')); } require_once "./protected/views/layout/{$layout}.php"; }
/** * @covers Cart::addProductByVariantId * @todo Implement testAddProductByVariantId(). */ public function testAddProductByVariantId() { try { $this->object->addProductByVariantId(994); } catch (Exception $exc) { echo $exc->getMessage(); } // Remove the following lines when you implement this test. // $this->markTestIncomplete( // 'This test has not been implemented yet.' // ); }
public function getTotalPriceByCart($cart) { $cartModel = new Cart(); $cartData = $cartModel->readFood(); $totalPrice = 0; foreach ($cartData as $foodId => $amount) { $foodData = $this->find('first', array('conditions' => array('Food.id' => $foodId))); $price = $foodData['Food']['price']; $totalPrice += $price * $amount; } return $totalPrice; }
public function sendCampaign() { // get abandoned cart : $sql = "SELECT * FROM (\n\t\tSELECT\n\t\tCONCAT(LEFT(c.`firstname`, 1), '. ', c.`lastname`) `customer`, a.id_cart total, ca.name carrier, c.id_customer, a.id_cart, a.date_upd,a.date_add,\n\t\t\t\tIF (IFNULL(o.id_order, 'Non ordered') = 'Non ordered', IF(TIME_TO_SEC(TIMEDIFF('" . date('Y-m-d H:i:s') . "', a.`date_add`)) > 86400, 'Abandoned cart', 'Non ordered'), o.id_order) id_order, IF(o.id_order, 1, 0) badge_success, IF(o.id_order, 0, 1) badge_danger, IF(co.id_guest, 1, 0) id_guest\n\t\tFROM `" . _DB_PREFIX_ . "cart` a \n\t\t\t\tJOIN `" . _DB_PREFIX_ . "customer` c ON (c.id_customer = a.id_customer)\n\t\t\t\tLEFT JOIN `" . _DB_PREFIX_ . "currency` cu ON (cu.id_currency = a.id_currency)\n\t\t\t\tLEFT JOIN `" . _DB_PREFIX_ . "carrier` ca ON (ca.id_carrier = a.id_carrier)\n\t\t\t\tLEFT JOIN `" . _DB_PREFIX_ . "orders` o ON (o.id_cart = a.id_cart)\n\t\t\t\tLEFT JOIN `" . _DB_PREFIX_ . "connections` co ON (a.id_guest = co.id_guest AND TIME_TO_SEC(TIMEDIFF('" . date('Y-m-d H:i:s') . "', co.`date_add`)) < 1800)\n\t\t) AS toto WHERE id_order='Abandoned cart'"; $currency = Context::getContext()->currency->sign; $defaultLanguage = new Language((int) Configuration::get('PS_LANG_DEFAULT')); $abandoned_carts = Db::getInstance()->ExecuteS($sql); // get all available campaigns $sqlCampaigns = 'SELECT * FROM `' . _DB_PREFIX_ . 'campaign` WHERE active=1'; $allCampaigns = Db::getInstance()->ExecuteS($sqlCampaigns); // loop on all abandoned carts foreach ($abandoned_carts as $abncart) { // loop on all available campaigns foreach ($allCampaigns as $camp) { $cartIsOnCampaign = $this->checkIfCartIsOnCampaign($abncart['date_add'], $camp['execution_time_day'], $camp['execution_time_hour']); if ($cartIsOnCampaign) { $id_lang = (int) Configuration::get('PS_LANG_DEFAULT'); $customer = new Customer($abncart['id_customer']); $cR = new CartRule($camp['id_voucher'], $id_lang); $cart = new Cart($abncart['id_cart']); $products = $cart->getProducts(); $campM = new Campaign($camp['id_campaign']); if (!empty($products)) { $cart_content = $campM->getCartContentHeader(); } else { $cart_content = ''; } foreach ($products as $prod) { $p = new Product($prod['id_product'], true, $id_lang); $price_no_tax = Product::getPriceStatic($p->id, false, null, 2, null, false, true, 1, false, null, $abncart['id_cart'], null, $null, true, true, null, false, false); $total_no_tax = $prod['cart_quantity'] * $price_no_tax; $images = Image::getImages((int) $id_lang, (int) $p->id); $link = new Link(); $cart_content .= '<tr > <td align="center" ><img src="' . $link->getImageLink($p->link_rewrite, $images[0]['id_image']) . '" width="80"/></td> <td align="center" ><a href="' . $link->getProductLink($p) . '"/>' . $p->name . '</a></td> <td align="center" >' . Tools::displayprice($price_no_tax) . '</td> <td align="center" >' . $prod['cart_quantity'] . '</td> <td align="center" >' . Tools::displayprice($total_no_tax) . '</td> </tr>'; } $tpl_vars = array('{firstname}' => $customer->firstname, '{lastname}' => $customer->lastname, '{coupon_name}' => $cR->name, '{coupon_code}' => $cR->code, '{cart_content}' => $cart_content, '{coupon_value}' => $camp['voucher_amount_type'] == 'percent' ? $cR->reduction_percent . '%' : $currency . $cR->reduction_amount, '{coupon_valid_to}' => date('d/m/Y', strtotime($cR->date_to)), '{campaign_name}' => $camp['name']); $path = _PS_ROOT_DIR_ . '/modules/superabandonedcart/mails/'; // send email to customer : Mail::Send($id_lang, $campM->getFileName(), $camp['name'], $tpl_vars, $customer->email, null, null, null, null, null, $path, false, Context::getContext()->shop->id); // Email to admin : Mail::Send($id_lang, $campM->getFileName(), Mail::l(sprintf('Email sent to %s %s for campaign %s', $customer->lastname, $customer->firstname, $camp['name'])), $tpl_vars, Configuration::get('PS_SHOP_EMAIL'), null, null, null, null, null, $path, false, Context::getContext()->shop->id); // echo 'ID ' . $abncart['id_cart']; } } } }
private function LoginedAction() { global $cookie, $smarty; if (!isset($cookie->id_cart)) { die('Shpping cart is empty!'); } $cart = new Cart((int) $cookie->id_cart); $user = new User((int) $cart->id_user); $addresses = $user->getAddresses(); $carriers = Carrier::loadData(); $payments = PaymentModule::getHookPayment(); $smarty->assign(array('cart' => $cart, 'addresses' => $addresses, 'carriers' => $carriers, 'payments' => $payments, 'products' => $cart->getProducts(), 'discount' => $cart->discount, 'total' => $cart->getProductTotal())); }
/** * Add to cart * * @throws HTTP_Exception_404 * @throws Kohana_Exception */ public function action_add() { $id = Arr::get($_POST, 'id'); $obj = ORM::factory('Shop_Product')->where('id', '=', $id)->where('enabled', '=', 1)->find(); if (!$obj->loaded()) { throw new HTTP_Exception_404(); } $product = ['id' => $obj->id, 'qty' => 1, 'price' => $obj->price, 'name' => $obj->title, 'slug' => $obj->slug]; $cart = new Cart(); $cart->insert($product); $this->json['success'] = true; $this->json['content'] = View::factory('shop/frontend/cart/v_cart_top', ['cart' => $cart])->render(); }
/** * Calculates shipping rates * * @param Cart $cart SHipping cart for which to calculate shipping * @param null $service * @internal param \Address $shipping_address Address to which products should be shipped * @return int|mixed */ public function calculateShipping(Cart $cart, $service = NULL) { if($this->type == 'per_item') { $products = $cart->getProducts(); $total_quantity = 0; foreach($products as $product) $total_quantity += $product->quantity; return $total_quantity * $this->price; } return $this->price; }
public function postProcess() { $cartId = Tools::getValue('id_cart', false); if (!$cartId) { Tools::redirect('index.php?controller=order-confirmation'); } $cart = new Cart((int) $cartId); if (!$cart->orderExists()) { $this->module->validateOrder($cart->id, Configuration::get('PS_OS_CANCELED'), $cart->getOrderTotal(), $this->module->displayName, 'Order cancelled by Aplazame cancel_url', null, null, false, Tools::getValue('key', false)); } $orderId = Order::getOrderByCartId($cart->id); Tools::redirect('index.php?controller=order-confirmation&id_cart=' . $cart->id . '&id_module=' . $this->module->id . '&id_order=' . $orderId . '&key=' . $cart->secure_key); }