public function __construct($id = null, $id_lang = null) { parent::__construct($id, $id_lang); // $this->def['fields']['delivery_date'] = array('type' => self::TYPE_DATE, 'validate' => 'isDate'); // $this->def['fields']['delivery_time_from'] = array('type' => self::TYPE_STRING, 'validate' => 'isGenericName'); // $this->def['fields']['delivery_time_to'] = array('type' => self::TYPE_STRING, 'validate' => 'isGenericName'); }
public function delete() { if ($this->OrderExists()) { //NOT delete a cart which is associated with an order return false; } $uploaded_files = Db::getInstance()->executeS(' SELECT cd.`value` FROM `' . _DB_PREFIX_ . 'customized_data` cd INNER JOIN `' . _DB_PREFIX_ . 'customization` c ON (cd.`id_customization`= c.`id_customization`) WHERE cd.`type`= 0 AND c.`id_cart`=' . (int) $this->id); foreach ($uploaded_files as $must_unlink) { unlink(_PS_UPLOAD_DIR_ . $must_unlink['value'] . '_small'); unlink(_PS_UPLOAD_DIR_ . $must_unlink['value']); } Db::getInstance()->execute(' DELETE FROM `' . _DB_PREFIX_ . 'customized_data` WHERE `id_customization` IN ( SELECT `id_customization` FROM `' . _DB_PREFIX_ . 'customization` WHERE `id_cart`=' . (int) $this->id . ' )'); Db::getInstance()->execute(' DELETE FROM `' . _DB_PREFIX_ . 'customization` WHERE `id_cart` = ' . (int) $this->id); if (!Db::getInstance()->execute('DELETE FROM `' . _DB_PREFIX_ . 'cart_cart_rule` WHERE `id_cart` = ' . (int) $this->id) || !Db::getInstance()->execute('DELETE FROM `' . _DB_PREFIX_ . 'cart_product` WHERE `id_cart` = ' . (int) $this->id)) { return false; } return parent::delete(); }
public function duplicate() { $result = parent::duplicate(); if (isset($result['cart'])) { $result['cart']->deleteProduct((int) Configuration::get('GOINTERPAY_ID_TAXES_TDUTIES')); } return $result; }
public function getDeliveryOption($default_country = null, $dontAutoSelectOptions = false, $use_cache = true) { @session_start(); if (Module::isInstalled('agilepaypal') && isset($_SESSION['agile_paypal_validating_order']) && $_SESSION['agile_paypal_validating_order'] == 1 && isset($this->delivery_option) && $this->delivery_option != '') { $_SESSION['agile_paypal_validating_order'] = 0; return Tools::unSerialize($this->delivery_option); } return parent::getDeliveryOption($default_country, $dontAutoSelectOptions, $use_cache); }
protected function _getProducts($refresh = false, $id_product = false, $id_country = null) { $products = parent::getProducts($refresh, $id_product, $id_country); if (_PS_VERSION_ >= 1.6) { $params = Hook::exec('ppbsGetProducts', array('products' => $products), null, true); if (isset($params['productpricebysize']['products'])) { return $params['productpricebysize']['products']; } else { return $products; } } else { $params = Hook::exec('ppbsGetProducts', array('products' => $products), null); $params = Tools::jsonDecode($params, true); if (isset($params['products'])) { return $params['products']; } else { return $products; } } }
public function isCarrierInRange($id_carrier, $id_zone) { if (version_compare(_PS_VERSION_, "1.4.2.5", "==") || version_compare(_PS_VERSION_, "1.4.3.0", "==")) { // fix a bug in Prestashop $carrier = new Carrier((int) $id_carrier, Configuration::get('PS_LANG_DEFAULT')); $shippingMethod = $carrier->getShippingMethod(); ###### that is the bug BOF ###### if (!$carrier->range_behavior) { return true; } ###### that is the bug EOF ###### if ($shippingMethod == Carrier::SHIPPING_METHOD_FREE) { return true; } if ($shippingMethod == Carrier::SHIPPING_METHOD_WEIGHT && Carrier::checkDeliveryPriceByWeight((int) $id_carrier, $this->getTotalWeight(), $id_zone)) { return true; } if ($shippingMethod == Carrier::SHIPPING_METHOD_PRICE && Carrier::checkDeliveryPriceByPrice((int) $id_carrier, $this->getOrderTotal(true, Cart::BOTH_WITHOUT_SHIPPING), $id_zone, (int) $this->id_currency)) { return true; } } elseif (version_compare(_PS_VERSION_, "1.4.1.0", "==")) { // fix a bug in prestashop $carrier = new Carrier((int) $id_carrier, Configuration::get('PS_LANG_DEFAULT')); $is_in_zone = false; $order_total = $this->getOrderTotal(true, Cart::BOTH_WITHOUT_SHIPPING); ###### that is the bug BOF ###### if (!$carrier->range_behavior) { return true; } ###### that is the bug EOF ###### if ($carrier->getShippingMethod() == Carrier::SHIPPING_METHOD_WEIGHT and Carrier::checkDeliveryPriceByWeight((int) $id_carrier, $this->getTotalWeight(), $id_zone) or $carrier->getShippingMethod() == Carrier::SHIPPING_METHOD_PRICE and Carrier::checkDeliveryPriceByPrice((int) $id_carrier, $order_total, $id_zone, (int) $this->id_currency)) { $is_in_zone = true; } unset($carrier); return $is_in_zone; } else { return parent::isCarrierInRange($id_carrier, $id_zone); } return false; }
public function getPackageShippingCost($id_carrier = null, $use_tax = true, Country $default_country = null, $product_list = null, $id_zone = null) { if (!Configuration::get('LEGAL_SHIPTAXMETH')) { return parent::getPackageShippingCost($id_carrier, $use_tax, $default_country, $product_list, $id_zone); } if ($this->isVirtualCart()) { return 0; } if (!$default_country) { $default_country = Context::getContext()->country; } if (!is_null($product_list)) { foreach ($product_list as $key => $value) { if ($value['is_virtual'] == 1) { unset($product_list[$key]); } } } $complete_product_list = $this->getProducts(); if (is_null($product_list)) { $products = $complete_product_list; } else { $products = $product_list; } if (Configuration::get('PS_TAX_ADDRESS_TYPE') == 'id_address_invoice') { $address_id = (int) $this->id_address_invoice; } elseif (count($product_list)) { $prod = current($product_list); $address_id = (int) $prod['id_address_delivery']; } else { $address_id = null; } if (!Address::addressExists($address_id)) { $address_id = null; } $cache_id = 'getPackageShippingCost_' . (int) $this->id . '_' . (int) $address_id . '_' . (int) $id_carrier . '_' . (int) $use_tax . '_' . (int) $default_country->id; if ($products) { foreach ($products as $product) { $cache_id .= '_' . (int) $product['id_product'] . '_' . (int) $product['id_product_attribute']; } } if (Cache::isStored($cache_id)) { return Cache::retrieve($cache_id); } // Order total in default currency without fees $order_total = $this->getOrderTotal(true, Cart::ONLY_PHYSICAL_PRODUCTS_WITHOUT_SHIPPING, $product_list); // Start with shipping cost at 0 $shipping_cost = 0; // If no product added, return 0 if (!count($products)) { Cache::store($cache_id, $shipping_cost); return $shipping_cost; } if (!isset($id_zone)) { // Get id zone if (!$this->isMultiAddressDelivery() && isset($this->id_address_delivery) && $this->id_address_delivery && Customer::customerHasAddress($this->id_customer, $this->id_address_delivery)) { $id_zone = Address::getZoneById((int) $this->id_address_delivery); } else { if (!Validate::isLoadedObject($default_country)) { $default_country = new Country(Configuration::get('PS_COUNTRY_DEFAULT'), Configuration::get('PS_LANG_DEFAULT')); } $id_zone = (int) $default_country->id_zone; } } if ($id_carrier && !$this->isCarrierInRange((int) $id_carrier, (int) $id_zone)) { $id_carrier = ''; } if (empty($id_carrier) && $this->isCarrierInRange((int) Configuration::get('PS_CARRIER_DEFAULT'), (int) $id_zone)) { $id_carrier = (int) Configuration::get('PS_CARRIER_DEFAULT'); } $total_package_without_shipping_tax_inc = $this->getOrderTotal(true, Cart::BOTH_WITHOUT_SHIPPING, $product_list); if (empty($id_carrier)) { if ((int) $this->id_customer) { $customer = new Customer((int) $this->id_customer); $result = Carrier::getCarriers((int) Configuration::get('PS_LANG_DEFAULT'), true, false, (int) $id_zone, $customer->getGroups()); unset($customer); } else { $result = Carrier::getCarriers((int) Configuration::get('PS_LANG_DEFAULT'), true, false, (int) $id_zone); } foreach ($result as $k => $row) { if ($row['id_carrier'] == Configuration::get('PS_CARRIER_DEFAULT')) { continue; } if (!isset(self::$_carriers[$row['id_carrier']])) { self::$_carriers[$row['id_carrier']] = new Carrier((int) $row['id_carrier']); } $carrier = self::$_carriers[$row['id_carrier']]; // Get only carriers that are compliant with shipping method if ($carrier->getShippingMethod() == Carrier::SHIPPING_METHOD_WEIGHT && $carrier->getMaxDeliveryPriceByWeight((int) $id_zone) === false || $carrier->getShippingMethod() == Carrier::SHIPPING_METHOD_PRICE && $carrier->getMaxDeliveryPriceByPrice((int) $id_zone) === false) { unset($result[$k]); continue; } // If out-of-range behavior carrier is set on "Desactivate carrier" if ($row['range_behavior']) { $check_delivery_price_by_weight = Carrier::checkDeliveryPriceByWeight($row['id_carrier'], $this->getTotalWeight(), (int) $id_zone); $total_order = $total_package_without_shipping_tax_inc; $check_delivery_price_by_price = Carrier::checkDeliveryPriceByPrice($row['id_carrier'], $total_order, (int) $id_zone, (int) $this->id_currency); // Get only carriers that have a range compatible with cart if ($carrier->getShippingMethod() == Carrier::SHIPPING_METHOD_WEIGHT && !$check_delivery_price_by_weight || $carrier->getShippingMethod() == Carrier::SHIPPING_METHOD_PRICE && !$check_delivery_price_by_price) { unset($result[$k]); continue; } } if ($carrier->getShippingMethod() == Carrier::SHIPPING_METHOD_WEIGHT) { $shipping = $carrier->getDeliveryPriceByWeight($this->getTotalWeight($product_list), (int) $id_zone); } else { $shipping = $carrier->getDeliveryPriceByPrice($order_total, (int) $id_zone, (int) $this->id_currency); } if (!isset($min_shipping_price)) { $min_shipping_price = $shipping; } if ($shipping <= $min_shipping_price) { $id_carrier = (int) $row['id_carrier']; $min_shipping_price = $shipping; } } } if (empty($id_carrier)) { $id_carrier = Configuration::get('PS_CARRIER_DEFAULT'); } if (!isset(self::$_carriers[$id_carrier])) { self::$_carriers[$id_carrier] = new Carrier((int) $id_carrier, Configuration::get('PS_LANG_DEFAULT')); } $carrier = self::$_carriers[$id_carrier]; // No valid Carrier or $id_carrier <= 0 ? if (!Validate::isLoadedObject($carrier)) { Cache::store($cache_id, 0); return 0; } if (!$carrier->active) { Cache::store($cache_id, $shipping_cost); return $shipping_cost; } // Free fees if free carrier if ($carrier->is_free == 1) { Cache::store($cache_id, 0); return 0; } // Select carrier tax if ($use_tax && !Tax::excludeTaxeOption()) { $address = Address::initialize((int) $address_id); $carrier_tax = $carrier->getTaxesRate($address); } $configuration = Configuration::getMultiple(array('PS_SHIPPING_FREE_PRICE', 'PS_SHIPPING_HANDLING', 'PS_SHIPPING_METHOD', 'PS_SHIPPING_FREE_WEIGHT')); // Free fees $free_fees_price = 0; if (isset($configuration['PS_SHIPPING_FREE_PRICE'])) { $free_fees_price = Tools::convertPrice((double) $configuration['PS_SHIPPING_FREE_PRICE'], Currency::getCurrencyInstance((int) $this->id_currency)); } $orderTotalwithDiscounts = $this->getOrderTotal(true, Cart::BOTH_WITHOUT_SHIPPING, null, null, false); if ($orderTotalwithDiscounts >= (double) $free_fees_price && (double) $free_fees_price > 0) { Cache::store($cache_id, $shipping_cost); return $shipping_cost; } if (isset($configuration['PS_SHIPPING_FREE_WEIGHT']) && $this->getTotalWeight() >= (double) $configuration['PS_SHIPPING_FREE_WEIGHT'] && (double) $configuration['PS_SHIPPING_FREE_WEIGHT'] > 0) { Cache::store($cache_id, $shipping_cost); return $shipping_cost; } // Get shipping cost using correct method if ($carrier->range_behavior) { if (!isset($id_zone)) { // Get id zone if (isset($this->id_address_delivery) && $this->id_address_delivery && Customer::customerHasAddress($this->id_customer, $this->id_address_delivery)) { $id_zone = Address::getZoneById((int) $this->id_address_delivery); } else { $id_zone = (int) $default_country->id_zone; } } if ($carrier->getShippingMethod() == Carrier::SHIPPING_METHOD_WEIGHT && !Carrier::checkDeliveryPriceByWeight($carrier->id, $this->getTotalWeight(), (int) $id_zone) || $carrier->getShippingMethod() == Carrier::SHIPPING_METHOD_PRICE && !Carrier::checkDeliveryPriceByPrice($carrier->id, $total_package_without_shipping_tax_inc, $id_zone, (int) $this->id_currency)) { $shipping_cost += 0; } else { if ($carrier->getShippingMethod() == Carrier::SHIPPING_METHOD_WEIGHT) { $shipping_cost += $carrier->getDeliveryPriceByWeight($this->getTotalWeight($product_list), $id_zone); } else { // by price $shipping_cost += $carrier->getDeliveryPriceByPrice($order_total, $id_zone, (int) $this->id_currency); } } } else { if ($carrier->getShippingMethod() == Carrier::SHIPPING_METHOD_WEIGHT) { $shipping_cost += $carrier->getDeliveryPriceByWeight($this->getTotalWeight($product_list), $id_zone); } else { $shipping_cost += $carrier->getDeliveryPriceByPrice($order_total, $id_zone, (int) $this->id_currency); } } // Adding handling charges if (isset($configuration['PS_SHIPPING_HANDLING']) && $carrier->shipping_handling) { $shipping_cost += (double) $configuration['PS_SHIPPING_HANDLING']; } // Additional Shipping Cost per product foreach ($products as $product) { if (!$product['is_virtual']) { $shipping_cost += $product['additional_shipping_cost'] * $product['cart_quantity']; } } $shipping_cost = Tools::convertPrice($shipping_cost, Currency::getCurrencyInstance((int) $this->id_currency)); //get external shipping cost from module if ($carrier->shipping_external) { $module_name = $carrier->external_module_name; $module = Module::getInstanceByName($module_name); if (Validate::isLoadedObject($module)) { if (array_key_exists('id_carrier', $module)) { $module->id_carrier = $carrier->id; } if ($carrier->need_range) { if (method_exists($module, 'getPackageShippingCost')) { $shipping_cost = $module->getPackageShippingCost($this, $shipping_cost, $products); } else { $shipping_cost = $module->getOrderShippingCost($this, $shipping_cost); } } else { $shipping_cost = $module->getOrderShippingCostExternal($this); } // Check if carrier is available if ($shipping_cost === false) { Cache::store($cache_id, false); return false; } } else { Cache::store($cache_id, false); return false; } } $shipping_cost = (double) Tools::ps_round((double) $shipping_cost, 2); Cache::store($cache_id, $shipping_cost); return $shipping_cost; }
protected function getFormattedProducts($cartId) { $formattedProducts = array(); $link = new Link(); $cart = new CartCore($cartId); $products = $cart->getProducts(); $currencyId = (int) Configuration::get('PS_CURRENCY_DEFAULT'); foreach ($products as $product) { $formattedProducts[] = array('name' => $product['name'], 'description' => strip_tags($product['description_short']), 'thumbnail' => 'http://' . $link->getImageLink($product['link_rewrite'], $product['id_image'], 'home_default'), 'quantity' => $product['quantity'], 'price' => Tools::displayPrice($product['price_wt'], $currencyId)); } return $formattedProducts; }
/** * Delete a product from the cart * * @param integer $id_product Product ID * @param integer $id_product_attribute Attribute ID if needed * @param integer $id_customization Customization id * @return boolean result */ public function deleteProduct($id_product, $id_product_attribute = NULL, $id_customization = NULL) { self::$_nbProducts = NULL; if ((int) $id_customization) { $productTotalQuantity = (int) Db::getInstance()->getValue('SELECT `quantity` FROM `' . _DB_PREFIX_ . 'cart_product` WHERE `id_product` = ' . (int) $id_product . ' AND `id_product_attribute` = ' . (int) $id_product_attribute); $customizationQuantity = (int) Db::getInstance()->getValue('SELECT `quantity` FROM `' . _DB_PREFIX_ . 'customization` WHERE `id_cart` = ' . (int) $this->id . ' AND `id_product` = ' . (int) $id_product . ' AND `id_product_attribute` = ' . (int) $id_product_attribute); if (!$this->_deleteCustomization((int) $id_customization, (int) $id_product, (int) $id_product_attribute)) { return false; } // refresh cache of self::_products $this->_products = $this->getProducts(true); return $customizationQuantity == $productTotalQuantity and $this->deleteProduct((int) $id_product, $id_product_attribute, NULL); } /* Get customization quantity */ if (($result = Db::getInstance()->getRow('SELECT SUM(`quantity`) AS \'quantity\' FROM `' . _DB_PREFIX_ . 'customization` WHERE `id_cart` = ' . (int) $this->id . ' AND `id_product` = ' . (int) $id_product . ' AND `id_product_attribute` = ' . (int) $id_product_attribute)) === false) { return false; } /* If the product still possesses customization it does not have to be deleted */ if (Db::getInstance()->NumRows() and (int) $result['quantity']) { return Db::getInstance()->Execute('UPDATE `' . _DB_PREFIX_ . 'cart_product` SET `quantity` = ' . (int) $result['quantity'] . ' WHERE `id_cart` = ' . (int) $this->id . ' AND `id_product` = ' . (int) $id_product . ($id_product_attribute != NULL ? ' AND `id_product_attribute` = ' . (int) $id_product_attribute : '')); } /* Product deletion */ if (Db::getInstance()->Execute('DELETE FROM `' . _DB_PREFIX_ . 'cart_product` WHERE `id_product` = ' . (int) $id_product . ($id_product_attribute != NULL ? ' AND `id_product_attribute` = ' . (int) $id_product_attribute : '') . ' AND `id_cart` = ' . (int) $this->id)) { // refresh cache of self::_products $this->_products = $this->getProducts(true); /* Update cart */ return $this->update(true); } return false; }
public function getPackageShippingCost($id_carrier = null, $use_tax = true, Country $default_country = null, $product_list = null, $id_zone = null) { include_once _PS_ROOT_DIR_ . '/modules/avalaratax/avalaratax.php'; /* Instanciate the Avalara module and check if active */ $avalara = new AvalaraTax(); if (!$avalara->active) { return parent::getPackageShippingCost((int) $id_carrier, $use_tax, $default_country, $product_list); } /* Retrieve the original carrier fee tax excluded */ $tax_excluded_cost = parent::getPackageShippingCost((int) $id_carrier, false, $default_country, $product_list); /* If we want price without tax or if this carrier is tax free, return this price */ if (!(int) $this->{Configuration::get('PS_TAX_ADDRESS_TYPE')} || !$use_tax) { return $tax_excluded_cost; } /* If there is no cache or cache expired, we regenerate it */ if (CacheTools::checkCarrierCache($this)) { return parent::getPackageShippingCost((int) $id_carrier, $use_tax, $default_country, $product_list); } /* If we do already know it, then return it */ return $tax_excluded_cost + (double) CacheTools::getCarrierTaxAmount($this); }
/** * Return shipping total of a specific carriers for the cart * * @param int $id_carrier Carrier ID * @param array $delivery_option Array of the delivery option for each address * @param bool $useTax Use Taxes * @param Country|null $default_country Default Country * @param array|null $delivery_option Delivery options array * * @return float Shipping total */ public function getCarrierCost($id_carrier, $useTax = true, Country $default_country = null, $delivery_option = null) { if (empty(self::$_total_shipping)) { if (is_null($delivery_option)) { $delivery_option = $this->getDeliveryOption($default_country); } $total_shipping = 0; $delivery_option_list = $this->getDeliveryOptionList(); foreach ($delivery_option as $id_address => $key) { if (!isset($delivery_option_list[$id_address]) || !isset($delivery_option_list[$id_address][$key])) { continue; } if (isset($delivery_option_list[$id_address][$key]['carrier_list'][$id_carrier])) { if ($useTax) { $total_shipping += $delivery_option_list[$id_address][$key]['carrier_list'][$id_carrier]['price_with_tax']; } else { $total_shipping += $delivery_option_list[$id_address][$key]['carrier_list'][$id_carrier]['price_without_tax']; } } } self::$_total_shipping = $total_shipping; } return self::$_total_shipping; }
public function getDeliveryAddressesWithoutCarriers($return_collection = false) { if (!Module::isInstalled('agilesellershipping')) { return parent::getDeliveryAddressesWithoutCarriers($return_collection); } return array(); }
private function generateCSV($collection) { // clean buffer if (ob_get_level() && ob_get_length() > 0) { ob_clean(); } $this->getList($this->context->language->id); if (!count($this->_list)) { return; } header('Content-type: text/csv'); header('Content-Type: application/force-download; charset=ISO-8859-2'); header('Cache-Control: no-store, no-cache'); header('Content-disposition: attachment; filename="' . $this->className . '_' . date('Y-m-d_His') . '.csv"'); $megrendelok = []; foreach ($collection as $i => $orderInvoice) { $order = new Order((int) $orderInvoice->id_order); $customer = new Customer((int) $order->id_customer); $cart = new CartCore((int) $order->id_cart); $megrendelok[$i] = ['order' => $order, 'order_invoice' => $orderInvoice, 'customer' => $customer, 'weight' => $cart->getTotalWeight(), 'address' => new Address((int) $order->id_address_invoice)]; } //var_dump($megrendelok); $this->context->smarty->assign(['megrendelok' => $megrendelok]); $this->layout = dirname(__FILE__) . '/../../views/templates/admin/csv.tpl'; }
public function resetCartDiscountCache() { // verification keys: VK##2 // reset discount cache so that discount can be added and new results retrieved in single HTTP request self::$_discounts = NULL; self::$_discountsLite = NULL; }
/** * @param CartCore $cart * @return string */ public function getLuForm(CartCore $cart) { $merchant_id = Configuration::get('PAYU_EPAYMENT_MERCHANT'); $secret_key = Configuration::get('PAYU_EPAYMENT_SECRET_KEY'); $url = $this->getBusinessPartnerSetting('lu_url'); if (empty($merchant_id) || empty($secret_key) || empty($url)) { return false; } $live_update = new PayuLu($merchant_id, $secret_key); $live_update->setQueryUrl($url); $this->validateOrder($cart->id, (int) Configuration::get('PAYU_PAYMENT_STATUS_PENDING'), $cart->getOrderTotal(true, Cart::BOTH), $this->displayName, null, null, (int) $cart->id_currency, false, $cart->secure_key, Context::getContext()->shop->id ? new Shop((int) Context::getContext()->shop->id) : null); $this->current_order = $this->{'currentOrder'}; if (version_compare(_PS_VERSION_, '1.5', 'lt')) { $this->current_order_reference = ''; $internal_reference = '#' . str_pad($this->current_order, 6, '0', STR_PAD_LEFT); $order_ref = $this->current_order . '|' . str_pad($this->current_order, 6, '0', STR_PAD_LEFT); $order_id = $this->current_order; $backref_url = $this->getModuleAddress() . 'backward_compatibility/return.php?order_ref=' . $this->current_order; } else { $this->current_order_reference = $this->{'currentOrderReference'}; $internal_reference = $this->{'currentOrderReference'}; $order_ref = $this->{'currentOrder'} . '|' . $this->{'currentOrderReference'}; $order_id = $this->{'currentOrder'}; $backref_url = Context::getContext()->link->getModuleLink('payu', 'return', array('order_ref' => $this->current_order)); } $live_update->setBackRef($backref_url); $live_update->setOrderRef($order_ref); $currency = Currency::getCurrency($cart->id_currency); $default_lang = (int) Configuration::get('PS_LANG_DEFAULT'); $lang_iso_code = Language::getIsoById($default_lang); $live_update->setPaymentCurrency($currency['iso_code']); $live_update->setLanguage(Tools::strtoupper($lang_iso_code)); $payu_product = new PayuProduct(); $payu_product->setName('Payment for order ' . $internal_reference); $payu_product->setCode($internal_reference); $payu_product->setPrice($cart->getOrderTotal(true, Cart::BOTH)); $payu_product->setTax(0); $payu_product->setQuantity(1); $live_update->addProduct($payu_product); if (!empty($cart->id_customer)) { $customer = new Customer((int) $cart->id_customer); if ($customer->email) { if (!empty($cart->id_address_invoice) && Configuration::get('PS_INVOICE')) { $address = new Address((int) $cart->id_address_invoice); $country = new Country((int) $address->id_country); $billing = new PayuAddress(); $billing->setFirstName($address->firstname); $billing->setLastName($address->lastname); $billing->setEmail($customer->email); $billing->setPhone(!$address->phone ? $address->phone_mobile : $address->phone); $billing->setAddress($address->address1); $billing->setAddress2($address->address2); $billing->setZipCode($address->postcode); $billing->setCity($address->city); $billing->setCountryCode(Tools::strtoupper($country->iso_code)); $live_update->setBillingAddress($billing); } if (!empty($cart->id_address_delivery)) { $address = new Address((int) $cart->id_address_delivery); $country = new Country((int) $address->id_country); $delivery = new PayuAddress(); $delivery->setFirstName($address->firstname); $delivery->setLastName($address->lastname); $delivery->setEmail($customer->email); $delivery->setPhone(!$address->phone ? $address->phone_mobile : $address->phone); $delivery->setAddress($address->address1); $delivery->setAddress2($address->address2); $delivery->setZipCode($address->postcode); $delivery->setCity($address->city); $delivery->setCountryCode(Tools::strtoupper($country->iso_code)); $live_update->setDeliveryAddress($delivery); } } } $lu_form = $live_update->renderPaymentForm(null); $this->savePayuTransaction($order_id, $cart->getOrderTotal(true, Cart::BOTH), Currency::getCurrency($cart->id_currency)); return $lu_form; }