本文整理汇总了PHP中Tax::getCarrierTaxRate方法的典型用法代码示例。如果您正苦于以下问题:PHP Tax::getCarrierTaxRate方法的具体用法?PHP Tax::getCarrierTaxRate怎么用?PHP Tax::getCarrierTaxRate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tax
的用法示例。
在下文中一共展示了Tax::getCarrierTaxRate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generateFlux
public function generateFlux()
{
if (Tools::getValue('token') == '' || Tools::getValue('token') != Configuration::get('SHOPPING_FLUX_TOKEN')) {
die('Invalid Token');
}
$titles = array(0 => 'id_produit', 1 => 'nom_produit', 2 => 'url_produit', 3 => 'url_image', 4 => 'description', 5 => 'description_courte', 6 => 'prix', 7 => 'prix_barre', 8 => 'frais_de_port', 9 => 'delaiLiv', 10 => 'marque', 11 => 'rayon', 12 => 'stock', 13 => 'qte_stock', 14 => 'EAN', 15 => 'poids', 16 => 'ecotaxe', 17 => 'TVA', 18 => 'Reference constructeur', 19 => 'Reference fournisseur');
echo implode("|", $titles) . "\r\n";
//For Shipping
$configuration = Configuration::getMultiple(array('PS_TAX_ADDRESS_TYPE', 'PS_CARRIER_DEFAULT', 'PS_COUNTRY_DEFAULT', 'PS_LANG_DEFAULT', 'PS_SHIPPING_FREE_PRICE', 'PS_SHIPPING_HANDLING', 'PS_SHIPPING_METHOD', 'PS_SHIPPING_FREE_WEIGHT'));
$products = Product::getSimpleProducts($configuration['PS_LANG_DEFAULT']);
$defaultCountry = new Country($configuration['PS_COUNTRY_DEFAULT'], Configuration::get('PS_LANG_DEFAULT'));
$id_zone = (int) $defaultCountry->id_zone;
$carrier = new Carrier((int) $configuration['PS_CARRIER_DEFAULT']);
$carrierTax = Tax::getCarrierTaxRate((int) $carrier->id, (int) $this->{$configuration['PS_TAX_ADDRESS_TYPE']});
foreach ($products as $key => $produit) {
$product = new Product((int) $produit['id_product'], true, $configuration['PS_LANG_DEFAULT']);
//For links
$link = new Link();
//For images
$cover = $product->getCover($product->id);
$ids = $product->id . '-' . $cover['id_image'];
//For shipping
if ($product->getPrice(true, NULL, 2, NULL, false, true, 1) >= (double) $configuration['PS_SHIPPING_FREE_PRICE'] and (double) $configuration['PS_SHIPPING_FREE_PRICE'] > 0) {
$shipping = 0;
} elseif (isset($configuration['PS_SHIPPING_FREE_WEIGHT']) and $product->weight >= (double) $configuration['PS_SHIPPING_FREE_WEIGHT'] and (double) $configuration['PS_SHIPPING_FREE_WEIGHT'] > 0) {
$shipping = 0;
} else {
if (isset($configuration['PS_SHIPPING_HANDLING']) and $carrier->shipping_handling) {
$shipping = (double) $configuration['PS_SHIPPING_HANDLING'];
}
if ($carrier->getShippingMethod() == Carrier::SHIPPING_METHOD_WEIGHT) {
$shipping += $carrier->getDeliveryPriceByWeight($product->weight, $id_zone);
} else {
$shipping += $carrier->getDeliveryPriceByPrice($product->getPrice(true, NULL, 2, NULL, false, true, 1), $id_zone);
}
$shipping *= 1 + $carrierTax / 100;
$shipping = (double) Tools::ps_round((double) $shipping, 2);
}
$data = array();
$data[0] = $product->id;
$data[1] = $product->name;
$data[2] = $link->getProductLink($product);
$data[3] = $link->getImageLink($product->link_rewrite, $ids, 'large');
$data[4] = $product->description;
$data[5] = $product->description_short;
$data[6] = $product->getPrice(true, NULL, 2, NULL, false, true, 1);
$data[7] = $product->getPrice(true, NULL, 2, NULL, false, false, 1);
$data[8] = $shipping;
$data[9] = $carrier->delay[2];
$data[10] = $product->manufacturer_name;
$data[11] = $product->category;
$data[12] = $product->quantity > 0 ? 'oui' : 'non';
$data[13] = $product->quantity;
$data[14] = $product->ean13;
$data[15] = $product->weight;
$data[16] = $product->ecotax;
$data[17] = $product->tax_rate;
$data[18] = $product->reference;
$data[19] = $product->supplier_reference;
foreach ($data as $key => $value) {
$data[$key] = $this->clean($value);
}
echo implode("|", $data) . "\r\n";
}
}
示例2: getOrderShippingCostPerSellerCarrier
public function getOrderShippingCostPerSellerCarrier($id_seller, $use_tax, $id_zone, $id_carrier, $carrier_amount, $carrier_weight)
{
$shipping_cost = 0;
$carrier = new Carrier($id_carrier, $this->id_lang);
if ($carrier->is_free == 1) {
return 0;
}
if ($use_tax and !Tax::excludeTaxeOption()) {
$carrierTax = Tax::getCarrierTaxRate((int) $carrier->id, (int) $this->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
}
$configuration = Configuration::getMultiple(array('PS_SHIPPING_FREE_PRICE', 'PS_SHIPPING_HANDLING', 'PS_SHIPPING_FREE_WEIGHT'));
$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));
}
$free_fees_weight = 0;
if (isset($configuration['PS_SHIPPING_FREE_WEIGHT'])) {
$free_fees_weight = Tools::convertPrice((double) $configuration['PS_SHIPPING_FREE_WEIGHT'], Currency::getCurrencyInstance((int) $this->id_currency));
}
$shipping_method = $carrier->getShippingMethod();
if ($shipping_method == Carrier::SHIPPING_METHOD_PRICE and $carrier_amount >= (double) $free_fees_price and (double) $free_fees_price > 0) {
} else {
if ($shipping_method == Carrier::SHIPPING_METHOD_WEIGHT and $carrier_weight >= (double) $free_fees_weight and (double) $free_fees_weight > 0) {
} else {
if ($shipping_method == Carrier::SHIPPING_METHOD_WEIGHT) {
$seller_shipping = $carrier->getDeliveryPriceByWeight($carrier_weight, $id_zone);
$shipping_cost += $seller_shipping;
} else {
$seller_shipping = $carrier->getDeliveryPriceByPrice($carrier_amount, $id_zone, (int) $this->id_currency);
$shipping_cost += $seller_shipping;
}
}
}
$shipping_cost += $this->getAdditionalShippingCostOfSeller($id_carrier);
if ($carrier->shipping_handling) {
$shipping_cost += (double) Configuration::get('PS_SHIPPING_HANDLING');
}
if (isset($carrierTax)) {
$shipping_cost *= 1 + $carrierTax / 100;
}
$shipping_cost = Tools::convertPrice($shipping_cost);
return $shipping_cost;
}
示例3: _getShippingPriceForProduct
private static function _getShippingPriceForProduct($product, $zone, $carrier_id)
{
$carrier = new Carrier($carrier_id);
if ($carrier->shipping_method == 0) {
// Default
if (Configuration::get('PS_SHIPPING_METHOD') == 1) {
// Shipping by weight
$price = $carrier->getDeliveryPriceByWeight($product->weight, $zone);
} else {
// Shipping by price
$price = $carrier->getDeliveryPriceByPrice($product->price, $zone);
}
} else {
if ($carrier->shipping_method == 1) {
// Shipping by weight
$price = $carrier->getDeliveryPriceByWeight($product->weight, $zone);
} else {
if ($carrier->shipping_method == 2) {
// Shipping by price
$price = $carrier->getDeliveryPriceByPrice($product->price, $zone);
} else {
// return 0 if is an other shipping method
return 0;
}
}
}
if ($carrier->shipping_handling) {
//Add shipping handling fee
$price += Configuration::get('PS_SHIPPING_HANDLING');
}
$price += $price * Tax::getCarrierTaxRate($carrier_id) / 100;
return $price;
}
示例4: validateOrder
/**
* Validate an order in database
* Function called from a payment module
*
* @param integer $id_cart Value
* @param integer $id_order_state Value
* @param float $amountPaid Amount really paid by customer (in the default currency)
* @param string $paymentMethod Payment method (eg. 'Credit card')
* @param string $message Message to attach to order
*/
public function validateOrder($id_cart, $id_order_state, $amountPaid, $paymentMethod = 'Unknown', $message = NULL, $extraVars = array(), $currency_special = NULL, $dont_touch_amount = false, $secure_key = false)
{
global $cart;
$cart = new Cart((int) $id_cart);
// Does order already exists ?
if (!$this->active) {
die(Tools::displayError());
}
if (Validate::isLoadedObject($cart) && $cart->OrderExists() == false) {
if ($secure_key !== false && $secure_key != $cart->secure_key) {
die(Tools::displayError());
}
// Copying data from cart
$order = new Order();
$order->id_carrier = (int) $cart->id_carrier;
$order->id_customer = (int) $cart->id_customer;
$order->id_address_invoice = (int) $cart->id_address_invoice;
$order->id_address_delivery = (int) $cart->id_address_delivery;
$vat_address = new Address((int) $order->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
$order->id_currency = $currency_special ? (int) $currency_special : (int) $cart->id_currency;
$order->id_lang = (int) $cart->id_lang;
$order->id_cart = (int) $cart->id;
$customer = new Customer((int) $order->id_customer);
$order->secure_key = $secure_key ? pSQL($secure_key) : pSQL($customer->secure_key);
$order->payment = $paymentMethod;
if (isset($this->name)) {
$order->module = $this->name;
}
$order->recyclable = $cart->recyclable;
$order->gift = (int) $cart->gift;
$order->gift_message = $cart->gift_message;
$currency = new Currency($order->id_currency);
$order->conversion_rate = $currency->conversion_rate;
$amountPaid = !$dont_touch_amount ? Tools::ps_round((double) $amountPaid, 2) : $amountPaid;
$order->total_paid_real = $amountPaid;
$order->total_products = (double) $cart->getOrderTotal(false, Cart::ONLY_PRODUCTS);
$order->total_products_wt = (double) $cart->getOrderTotal(true, Cart::ONLY_PRODUCTS);
$order->total_discounts = (double) abs($cart->getOrderTotal(true, Cart::ONLY_DISCOUNTS));
$order->total_shipping = (double) $cart->getOrderShippingCost();
$order->carrier_tax_rate = (double) Tax::getCarrierTaxRate($cart->id_carrier, (int) $cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
$order->total_wrapping = (double) abs($cart->getOrderTotal(true, Cart::ONLY_WRAPPING));
$order->total_paid = (double) Tools::ps_round((double) $cart->getOrderTotal(true, Cart::BOTH), 2);
$order->invoice_date = '0000-00-00 00:00:00';
$order->delivery_date = '0000-00-00 00:00:00';
// Amount paid by customer is not the right one -> Status = payment error
// We don't use the following condition to avoid the float precision issues : http://www.php.net/manual/en/language.types.float.php
// if ($order->total_paid != $order->total_paid_real)
// We use number_format in order to compare two string
if (number_format($order->total_paid, 2) != number_format($order->total_paid_real, 2)) {
$id_order_state = Configuration::get('PS_OS_ERROR');
}
// Creating order
if ($cart->OrderExists() == false) {
$result = $order->add();
} else {
$errorMessage = Tools::displayError('An order has already been placed using this cart.');
Logger::addLog($errorMessage, 4, '0000001', 'Cart', intval($order->id_cart));
die($errorMessage);
}
// Next !
if ($result and isset($order->id)) {
if (!$secure_key) {
$message .= $this->l('Warning : the secure key is empty, check your payment account before validation');
}
// Optional message to attach to this order
if (isset($message) and !empty($message)) {
$msg = new Message();
$message = strip_tags($message, '<br>');
if (Validate::isCleanHtml($message)) {
$msg->message = $message;
$msg->id_order = intval($order->id);
$msg->private = 1;
$msg->add();
}
}
// Insert products from cart into order_detail table
$products = $cart->getProducts();
$productsList = '';
$db = Db::getInstance();
$query = 'INSERT INTO `' . _DB_PREFIX_ . 'order_detail`
(`id_order`, `product_id`, `product_attribute_id`, `product_name`, `product_quantity`, `product_quantity_in_stock`, `product_price`, `reduction_percent`, `reduction_amount`, `group_reduction`, `product_quantity_discount`, `product_ean13`, `product_upc`, `product_reference`, `product_supplier_reference`, `product_weight`, `tax_name`, `tax_rate`, `ecotax`, `ecotax_tax_rate`, `discount_quantity_applied`, `download_deadline`, `download_hash`)
VALUES ';
$customizedDatas = Product::getAllCustomizedDatas((int) $order->id_cart);
Product::addCustomizationPrice($products, $customizedDatas);
$outOfStock = false;
$store_all_taxes = array();
foreach ($products as $key => $product) {
$productQuantity = (int) Product::getQuantity((int) $product['id_product'], $product['id_product_attribute'] ? (int) $product['id_product_attribute'] : NULL);
$quantityInStock = $productQuantity - (int) $product['cart_quantity'] < 0 ? $productQuantity : (int) $product['cart_quantity'];
if ($id_order_state != Configuration::get('PS_OS_CANCELED') and $id_order_state != Configuration::get('PS_OS_ERROR')) {
//.........这里部分代码省略.........
示例5: _getShipping
private function _getShipping($product, $configuration, $carrier, $attribute_id = null, $attribute_weight = null)
{
$default_country = new Country($configuration['PS_COUNTRY_DEFAULT'], $configuration['PS_LANG_DEFAULT']);
$id_zone = (int) $default_country->id_zone;
$this->id_address_delivery = 0;
$carrier_tax = Tax::getCarrierTaxRate((int) $carrier->id, (int) $this->{$configuration['PS_TAX_ADDRESS_TYPE']});
$shipping = 0;
$product_price = $product->getPrice(true, $attribute_id, 2, null, false, true, 1);
$shipping_free_price = $configuration['PS_SHIPPING_FREE_PRICE'];
$shipping_free_weight = isset($configuration['PS_SHIPPING_FREE_WEIGHT']) ? $configuration['PS_SHIPPING_FREE_WEIGHT'] : 0;
if (!((double) $shipping_free_price > 0 && $product_price >= (double) $shipping_free_price) && !((double) $shipping_free_weight > 0 && $product->weight + $attribute_weight >= (double) $shipping_free_weight)) {
if (isset($configuration['PS_SHIPPING_HANDLING']) && $carrier->shipping_handling) {
$shipping = (double) $configuration['PS_SHIPPING_HANDLING'];
}
if ($carrier->getShippingMethod() == Carrier::SHIPPING_METHOD_WEIGHT) {
$shipping += $carrier->getDeliveryPriceByWeight($product->weight, $id_zone);
} else {
$shipping += $carrier->getDeliveryPriceByPrice($product_price, $id_zone);
}
$shipping *= 1 + $carrier_tax / 100;
$shipping = (double) Tools::ps_round((double) $shipping, 2);
}
return (double) $shipping + (double) $product->additional_shipping_cost;
}
示例6: addTax
public function addTax($cena)
{
if (Configuration::get('PS_TAX')) {
if ($this->tax_rate === false) {
$this->taxrate = Tax::getCarrierTaxRate(Configuration::get($this->uppername . '_CARRIER_ID'));
}
$cena = $cena / 100 * (100 + $this->taxrate);
}
return $cena;
}
示例7: getShippingPriceForProduct
private function getShippingPriceForProduct($product, $zone, $carrierid)
{
$carrier = new Carrier($carrierid);
if (Configuration::get('PS_SHIPPING_METHOD') == 1) {
//Shipping by weight
$price = $carrier->getDeliveryPriceByWeight($product->weight, $zone);
} else {
//Shipping by price
$price = $carrier->getDeliveryPriceByPrice($product->price, $zone);
}
if ($carrier->shipping_handling) {
//Add shipping handling fee (frais de manutention)
$price += Configuration::get('PS_SHIPPING_HANDLING');
}
$taxrate = Tax::getCarrierTaxRate($carrierid);
$price += $price * $taxrate / 100;
return $price;
}
示例8: hookProductFooter
public function hookProductFooter($params)
{
global $cookie, $smarty;
$pr = new Product($params['product']->id);
$carriers = Carrier::getCarriers($cookie->id_lang);
$c = array();
foreach ($carriers as $carrier) {
$a = new Carrier($carrier['id_carrier']);
if (!Tax::excludeTaxeOption()) {
$carrierTax = Tax::getCarrierTaxRate((int) $a->id);
}
$price = $a->getDeliveryPriceByPrice($pr->getPrice(true, null), 1) * (1 + $carrierTax / 100);
$c[] = array('name' => $a->name, 'price' => $price);
}
$smarty->assign('carriers', $c);
$smarty->assign('free', (int) Configuration::get('PS_SHIPPING_FREE_PRICE'));
$smarty->assign(array('delivery' => $this->doruceni()));
return $this->display(__FILE__, 'blank_deliverytime.tpl');
}
示例9: initReservation
public function initReservation($klarna, $cart, $customer, $house = null, $ext = null)
{
$address_invoice = new Address((int) $cart->id_address_invoice);
$carrier = new Carrier((int) $cart->id_carrier);
$country = new Country((int) $address_invoice->id_country);
$id_currency = (int) Validate::isLoadedObject($this->context->currency) ? (int) $this->context->currency->id : (int) Configuration::get('PS_CURRENCY_DEFAULT');
$order_id = Order::getOrderByCartId((int) $cart->id);
if ($order_id) {
$order = new Order((int) $order_id);
foreach ($order->getProducts() as $article) {
$price_wt = (double) $article['product_price_wt'];
$price = (double) $article['product_price'];
if (empty($article['tax_rate'])) {
$rate = round(($price_wt / $price - 1.0) * 100);
} else {
$rate = $article['tax_rate'];
}
$klarna->addArticle((int) $article['product_quantity'], $this->klarnaEncode($article['product_id']), $this->klarnaEncode($article['product_name']), $price_wt, $rate, 0, KlarnaFlags::INC_VAT | (substr($article['product_name'], 0, 10) == 'invoiceFee' ? KlarnaFlags::IS_HANDLING : 0));
}
} else {
foreach ($cart->getProducts() as $article) {
$price_wt = (double) $article['price_wt'];
$price = (double) $article['price'];
if (empty($article['rate'])) {
$rate = round(($price_wt / $price - 1.0) * 100);
} else {
$rate = $article['rate'];
}
$klarna->addArticle((int) $article['cart_quantity'], $this->klarnaEncode((int) $article['id_product']), $this->klarnaEncode($article['name'] . (isset($article['attributes']) ? $article['attributes'] : '')), $price_wt, $rate, 0, KlarnaFlags::INC_VAT | (substr($article['name'], 0, 10) == 'invoiceFee' ? KlarnaFlags::IS_HANDLING : 0));
}
}
// Add discounts
if (_PS_VERSION_ >= 1.5) {
$discounts = $cart->getCartRules();
} else {
$discounts = $cart->getDiscounts();
}
foreach ($discounts as $discount) {
$rate = 0;
$incvat = 0;
// Free shipping has a real value of '!'.
if ($discount['value_real'] !== '!') {
$incvat = $discount['value_real'];
$extvat = $discount['value_tax_exc'];
$rate = round(($incvat / $extvat - 1.0) * 100);
}
$klarna->addArticle(1, '', $this->klarnaEncode($discount['description']), $incvat * -1, $rate, 0, KlarnaFlags::INC_VAT);
}
$carrier = new Carrier((int) $cart->id_carrier);
if ($carrier->active) {
$taxrate = Tax::getCarrierTaxRate((int) $carrier->id, (int) $cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
// Next we might want to add a shipment fee for the product
if ($order_id) {
$order = new Order((int) $order_id);
$shippingPrice = $order->total_shipping_tax_incl;
} else {
$shippingPrice = $cart->getTotalShippingCost();
}
$klarna->addArticle(1, $this->klarnaEncode((int) $cart->id_carrier), $this->klarnaEncode($carrier->name), $shippingPrice, $taxrate, 0, KlarnaFlags::INC_VAT | KlarnaFlags::IS_SHIPMENT);
}
if ($cart->gift == 1) {
$rate = 0;
$wrapping_fees_tax = new Tax((int) Configuration::get('PS_GIFT_WRAPPING_TAX'));
if ($wrapping_fees_tax->rate !== null) {
$rate = $wrapping_fees_tax->rate;
}
$klarna->addArticle(1, '', $this->klarnaEncode($this->l('Gift wrapping fee')), $cart->getOrderTotal(true, Cart::ONLY_WRAPPING), $rate, 0, KlarnaFlags::INC_VAT);
}
// Create the address object and specify the values.
$address_delivery = new Address((int) $cart->id_address_delivery);
// Next we tell the Klarna instance to use the address in the next order.
$address = str_replace($house, '', $address_invoice->address1);
$address = str_replace($ext, '', $address);
$address2 = str_replace($house, '', $address_invoice->address2);
$address2 = str_replace($ext, '', $address2);
$klarna->setAddress(KlarnaFlags::IS_BILLING, new KlarnaAddr($this->klarnaEncode($customer->email), $this->klarnaEncode($address_invoice->phone), $this->klarnaEncode($address_invoice->phone_mobile), $this->klarnaEncode($address_invoice->firstname), $this->klarnaEncode($address_invoice->lastname), $this->klarnaEncode($address_invoice->company), $this->klarnaEncode(trim($address) . ($address2 != '' ? ' ' . trim($address2) : '')), $this->klarnaEncode($address_invoice->postcode), $this->klarnaEncode($address_invoice->city), $this->klarnaEncode($this->countries[$country->iso_code]['code']), trim($house), trim($ext)));
// Billing / invoice address
$address = str_replace($house, '', $address_delivery->address1);
$address = str_replace($ext, '', $address);
$address2 = str_replace($house, '', $address_delivery->address2);
$address2 = str_replace($ext, '', $address2);
$klarna->setAddress(KlarnaFlags::IS_SHIPPING, new KlarnaAddr($this->klarnaEncode($customer->email), $this->klarnaEncode($address_delivery->phone), $this->klarnaEncode($address_delivery->phone_mobile), $this->klarnaEncode($address_delivery->firstname), $this->klarnaEncode($address_delivery->lastname), $this->klarnaEncode($address_delivery->company), $this->klarnaEncode(trim($address) . ($address2 != '' ? ' ' . trim($address2) : '')), $this->klarnaEncode($address_delivery->postcode), $this->klarnaEncode($address_delivery->city), $this->klarnaEncode($this->countries[$country->iso_code]['code']), trim($house), trim($ext)));
// Billing / invoice address
}
示例10: updatePrice
public function updatePrice()
{
$total_price_tax_excl = 0;
$total_shipping_tax_incl = 0;
$total_shipping_tax_excl = 0;
$id_carrier = (int) EbayShipping::getPsCarrierByEbayCarrier($this->shippingService);
if (version_compare(_PS_VERSION_, '1.4.0.5', '<')) {
$carrier_tax_rate = (double) $this->_getTaxByCarrier((int) $id_carrier);
} else {
$carrier_tax_rate = (double) Tax::getCarrierTaxRate((int) $id_carrier);
}
foreach ($this->product_list as $product) {
if (version_compare(_PS_VERSION_, '1.4.0.5', '<')) {
$tax_rate = (double) $this->_getTaxByProduct((int) $product['id_product']);
} else {
$tax_rate = (double) Tax::getProductTaxRate((int) $product['id_product']);
}
$coef_rate = 1 + $tax_rate / 100;
$detail_data = array('product_price' => (double) ($product['price'] / $coef_rate), 'unit_price_tax_incl' => (double) $product['price'], 'unit_price_tax_excl' => (double) ($product['price'] / $coef_rate), 'total_price_tax_incl' => (double) ($product['price'] * $product['quantity']), 'total_price_tax_excl' => (double) ($product['price'] / $coef_rate * $product['quantity']), 'reduction_percent' => 0, 'reduction_amount' => 0);
Db::getInstance()->autoExecute(_DB_PREFIX_ . 'order_detail', $detail_data, 'UPDATE', '`id_order` = ' . (int) $this->id_order . ' AND `product_id` = ' . (int) $product['id_product'] . ' AND `product_attribute_id` = ' . (int) $product['id_product_attribute']);
if (version_compare(_PS_VERSION_, '1.5', '>')) {
$detail_tax_data = array('unit_amount' => (double) ($product['price'] - $product['price'] / $coef_rate), 'total_amount' => (double) ($product['price'] - $product['price'] / $coef_rate) * $product['quantity']);
DB::getInstance()->autoExecute(_DB_PREFIX_ . 'order_detail_tax', $detail_tax_data, 'UPDATE', '`id_order_detail` = (SELECT `id_order_detail` FROM `' . _DB_PREFIX_ . 'order_detail` WHERE `id_order` = ' . (int) $this->id_order . ' AND `product_id` = ' . (int) $product['id_product'] . ' AND `product_attribute_id` = ' . (int) $product['id_product_attribute'] . ') ');
}
$total_price_tax_excl += (double) ($product['price'] / $coef_rate * $product['quantity']);
// ebay get one shipping cost by product
$total_shipping_tax_incl += $this->shippingServiceCost;
$total_shipping_tax_excl += $this->shippingServiceCost / (1 + $carrier_tax_rate / 100);
}
$data = array('total_paid' => (double) $this->amount, 'total_paid_real' => (double) $this->amount, 'total_products' => (double) $total_price_tax_excl, 'total_products_wt' => (double) ($this->amount - $this->shippingServiceCost), 'total_shipping' => (double) $total_shipping_tax_incl, 'total_shipping_tax_incl' => (double) $total_shipping_tax_incl, 'total_shipping_tax_excl' => (double) $total_shipping_tax_excl);
if ((double) $this->shippingServiceCost == 0) {
$data = array_merge($data, array('total_shipping_tax_excl' => 0, 'total_shipping_tax_incl' => 0));
}
if (version_compare(_PS_VERSION_, '1.5', '>')) {
$order = new Order((int) $this->id_order);
$data_old = $data;
$data = array_merge($data, array('total_paid_tax_incl' => (double) $this->amount, 'total_paid_tax_excl' => (double) ($total_price_tax_excl + $order->total_shipping_tax_excl)));
// Update Incoice
$invoice_data = $data;
unset($invoice_data['total_paid'], $invoice_data['total_paid_real'], $invoice_data['total_shipping']);
Db::getInstance()->autoExecute(_DB_PREFIX_ . 'order_invoice', $invoice_data, 'UPDATE', '`id_order` = ' . (int) $this->id_order);
// Update payment
$payment_data = array('amount' => (double) $this->amount);
Db::getInstance()->autoExecute(_DB_PREFIX_ . 'order_payment', $payment_data, 'UPDATE', '`order_reference` = "' . pSQL($order->reference) . '" ');
}
return Db::getInstance()->autoExecute(_DB_PREFIX_ . 'orders', $data, 'UPDATE', '`id_order` = ' . (int) $this->id_order);
}
示例11: cartToOrder
private function cartToOrder($items, $foreignKey)
{
$this->alterTable('order');
foreach ($items as $item) {
$order = new Order();
$order->id_carrier = (int) $item['id_carrier'];
$order->id_customer = (int) $foreignKey['id_customer'][$item['id_customer']];
$order->id_address_invoice = (int) $foreignKey['id_address_invoice'][$item['id_address_invoice']];
$order->id_address_delivery = (int) $foreignKey['id_address_delivery'][$item['id_address_delivery']];
$vat_address = new Address((int) $foreignKey['id_address_delivery'][$item['id_address_delivery']]);
$id_zone = Address::getZoneById((int) $vat_address->id);
$order->id_currency = (int) $item['id_currency'];
$order->id_lang = (int) $item['id_lang'];
$order->id_cart = (int) $foreignKey['id_cart'][$item['id_cart']];
$customer = new Customer((int) $order->id_customer);
$order->secure_key = pSQL($customer->secure_key);
$order->payment = Tools::substr($item['payment'], 0, 32);
if (isset($this->name)) {
$order->module = $this->name;
}
$currency = new Currency($order->id_currency);
$order->conversion_rate = $currency->conversion_rate;
$order->total_products = (double) $item['total_products'];
$order->total_products_wt = (double) $item['total_products_wt'];
$order->total_discounts = (double) $item['total_discounts'];
$order->total_shipping = (double) $item['total_shipping'];
$order->carrier_tax_rate = (double) Tax::getCarrierTaxRate((int) $item['id_carrier'], (int) $item[Configuration::get('PS_TAX_ADDRESS_TYPE')]);
$order->total_wrapping = (double) $item['total_wrapping'];
$order->total_paid = (double) $item['total_paid'];
$order->total_paid_real = (double) $item['total_paid_real'];
$order->invoice_date = '0000-00-00 00:00:00';
$order->delivery_date = '0000-00-00 00:00:00';
$order->add();
$this->saveMatchId('order', (int) $order->id, (int) $item['id_cart']);
}
}
示例12: hookExtraCarrier
public function hookExtraCarrier($params)
{
$carrier_so = new Carrier((int) Configuration::get('SOCOLISSIMO_CARRIER_ID'));
if (!isset($carrier_so) || !$carrier_so->active) {
return '';
}
$country = new Country((int) $params['address']->id_country);
$carriers = Carrier::getCarriers($this->context->language->id, true, false, false, null, defined('ALL_CARRIERS') ? ALL_CARRIERS : Carrier::ALL_CARRIERS);
// Backward compatibility 1.5
$id_carrier = $carrier_so->id;
// bug fix for cart rule with restriction
if (!version_compare(_PS_VERSION_, '1.5', '<')) {
CartRule::autoAddToCart($this->context);
}
// For now works only with single shipping !
if (method_exists($params['cart'], 'carrierIsSelected')) {
if ($params['cart']->carrierIsSelected((int) $carrier_so->id, $params['address']->id)) {
$id_carrier = (int) $carrier_so->id;
}
}
$customer = new Customer($params['address']->id_customer);
$gender = array('1' => 'MR', '2' => 'MME', '3' => 'MLE');
if (in_array((int) $customer->id_gender, array(1, 2))) {
$cecivility = $gender[(int) $customer->id_gender];
} else {
$cecivility = 'MR';
}
$tax_rate = Tax::getCarrierTaxRate($id_carrier, isset($params['cart']->id_address_delivery) ? $params['cart']->id_address_delivery : null);
$tax_rate_seller = Tax::getCarrierTaxRate(Configuration::get('SOCOLISSIMO_CARRIER_ID_SELLER'), isset($params['cart']->id_address_delivery) ? $params['cart']->id_address_delivery : null);
if ($tax_rate) {
$std_cost_with_taxes = number_format((double) $this->initial_cost * (1 + $tax_rate / 100), 2, ',', ' ');
} else {
$std_cost_with_taxes = number_format((double) $this->initial_cost, 2, ',', ' ');
}
$seller_cost_with_taxes = 0;
if ($this->seller_cost) {
if ($tax_rate_seller) {
$seller_cost_with_taxes = number_format((double) $this->seller_cost * (1 + $tax_rate_seller / 100), 2, ',', ' ');
} else {
$seller_cost_with_taxes = number_format((double) $this->seller_cost, 2, ',', ' ');
}
}
$free_shipping = false;
if (version_compare(_PS_VERSION_, '1.5', '<')) {
$rules = $params['cart']->getDiscounts();
if (!empty($rules)) {
foreach ($rules as $rule) {
if ($rule['id_discount_type'] == 3) {
$free_shipping = true;
break;
}
}
}
} else {
$rules = $params['cart']->getCartRules();
if (!empty($rules)) {
foreach ($rules as $rule) {
if ($rule['free_shipping'] && !$rule['carrier_restriction']) {
$free_shipping = true;
break;
}
}
if (!$free_shipping) {
$key_search = $id_carrier . ',';
$deliveries_list = $params['cart']->getDeliveryOptionList();
foreach ($deliveries_list as $deliveries) {
foreach ($deliveries as $key => $elt) {
if ($key == $key_search) {
$free_shipping = $elt['is_free'];
}
}
}
}
} else {
// for cart rule with restriction
$key_search = $id_carrier . ',';
$deliveries_list = $params['cart']->getDeliveryOptionList();
foreach ($deliveries_list as $deliveries) {
foreach ($deliveries as $key => $elt) {
if ($key == $key_search) {
$free_shipping = $elt['is_free'];
}
}
}
}
}
if ($free_shipping) {
$std_cost_with_taxes = 0;
$seller_cost_with_taxes = 0;
}
// Keep this fields order (see doc.)
$inputs = array('pudoFOId' => Configuration::get('SOCOLISSIMO_ID'), 'ceName' => $this->replaceAccentedChars(Tools::substr($params['address']->lastname, 0, 34)), 'dyPreparationTime' => (int) Configuration::Get('SOCOLISSIMO_PREPARATION_TIME'), 'dyForwardingCharges' => $std_cost_with_taxes, 'dyForwardingChargesCMT' => $seller_cost_with_taxes, 'trClientNumber' => (int) $params['address']->id_customer, 'orderId' => $this->formatOrderId((int) $params['address']->id), 'numVersion' => $this->getNumVersion(), 'ceCivility' => $cecivility, 'ceFirstName' => $this->replaceAccentedChars(Tools::substr($params['address']->firstname, 0, 29)), 'ceCompanyName' => $this->replaceAccentedChars(Tools::substr($params['address']->company, 0, 38)), 'ceAdress3' => $this->replaceAccentedChars(Tools::substr($params['address']->address1, 0, 38)), 'ceAdress4' => $this->replaceAccentedChars(Tools::substr($params['address']->address2, 0, 38)), 'ceZipCode' => $this->replaceAccentedChars($params['address']->postcode), 'ceTown' => $this->replaceAccentedChars(Tools::substr($params['address']->city, 0, 32)), 'ceEmail' => $this->replaceAccentedChars($params['cookie']->email), 'cePhoneNumber' => $this->replaceAccentedChars(str_replace(array(' ', '.', '-', ',', ';', '/', '\\', '(', ')'), '', $params['address']->phone_mobile)), 'dyWeight' => (double) $params['cart']->getTotalWeight() * 1000, 'trParamPlus' => $carrier_so->id, 'trReturnUrlKo' => htmlentities($this->url, ENT_NOQUOTES, 'UTF-8'), 'trReturnUrlOk' => htmlentities($this->url, ENT_NOQUOTES, 'UTF-8'), 'CHARSET' => 'UTF-8', 'cePays' => $country->iso_code, 'trInter' => Configuration::get('SOCOLISSIMO_EXP_BEL'), 'ceLang' => 'FR');
if (!$inputs['dyForwardingChargesCMT'] && !Configuration::get('SOCOLISSIMO_COST_SELLER')) {
unset($inputs['dyForwardingChargesCMT']);
}
// set params for Api 3.0 if needed
$inputs = $this->setInputParams($inputs);
// generate key for API
$inputs['signature'] = $this->generateKey($inputs);
// calculate lowest cost
//.........这里部分代码省略.........
示例13: _getCarriers
/**
* create carriers
*
* @return mixed
*/
protected function _getCarriers()
{
$resultsCarrier = array();
$mobileCarrierUse = unserialize(base64_decode(Configuration::get('SG_MOBILE_CARRIER')));
if ($this->_deliveryAddress) {
foreach (Carrier::getCarriersForOrder(Address::getZoneById($this->_deliveryAddress->id), $this->getPlugin()->getContext()->customer->getGroups(), $this->getPlugin()->getContext()->cart) as $carrier) {
/** @var CarrierCore $carrierItem */
$carrierItem = new Carrier($carrier['id_carrier'], $this->getPlugin()->getContext()->language->id);
$taxRulesGroup = new TaxRulesGroup($carrierItem->id_tax_rules_group);
$resultCarrier = new ShopgateShippingMethod();
/**
* check is defined as mobile carrier
*/
$idColumn = version_compare(_PS_VERSION_, '1.5.0.1', '>=') ? 'id_reference' : 'id_carrier';
if (is_array($mobileCarrierUse) && empty($mobileCarrierUse[$carrier[$idColumn]])) {
continue;
}
$resultCarrier->setId($carrier['id_carrier']);
$resultCarrier->setTitle($carrier['name']);
$resultCarrier->setDescription($carrier['delay']);
$resultCarrier->setSortOrder($carrier['position']);
$resultCarrier->setAmount($carrier['price_tax_exc']);
$resultCarrier->setAmountWithTax($carrier['price']);
$resultCarrier->setTaxClass($taxRulesGroup->name);
if (version_compare(_PS_VERSION_, '1.5.0', '<')) {
$carrierTax = Tax::getCarrierTaxRate($carrierItem->id, $this->_deliveryAddress->id);
} else {
$carrierTax = $carrierItem->getTaxesRate($this->_deliveryAddress);
}
$resultCarrier->setTaxPercent($carrierTax);
$resultCarrier->setInternalShippingInfo(serialize(array('carrierId' => $carrier['id_carrier'])));
$resultsCarrier[] = $resultCarrier;
}
}
return $resultsCarrier;
}
示例14: cartToOrder
private function cartToOrder($items, $foreignKey)
{
$this->alterTable('order');
foreach ($items as $item) {
$order = new Order();
$order->id_carrier = (int) $item['id_carrier'];
$order->id_customer = (int) $foreignKey['id_customer'][$item['id_customer']];
$order->id_address_invoice = (int) $foreignKey['id_address_invoice'][$item['id_address_invoice']];
$order->id_address_delivery = (int) $foreignKey['id_address_delivery'][$item['id_address_delivery']];
$vat_address = new Address((int) $foreignKey['id_address_delivery'][$item['id_address_delivery']]);
$id_zone = Address::getZoneById((int) $vat_address->id);
$order->id_currency = (int) $item['id_currency'];
$order->id_lang = (int) $item['id_lang'];
$order->id_cart = (int) $foreignKey['id_cart'][$item['id_cart']];
$customer = new Customer((int) $order->id_customer);
$order->secure_key = pSQL($customer->secure_key);
if (!strlen(trim($item['payment']))) {
$order->payment = 'payment' . Tools::getValue('moduleName');
} else {
$order->payment = utf8_encode(html_entity_decode(strip_tags(Tools::substr($item['payment'], 0, 32))));
}
if (isset($this->name)) {
$order->module = $this->name;
}
$currency = new Currency($order->id_currency);
$order->conversion_rate = !empty($currency->conversion_rate) ? $currency->conversion_rate : 1;
$order->total_products = (double) $item['total_products'];
$order->total_products_wt = (double) $item['total_products_wt'];
$order->total_discounts = (double) $item['total_discounts'];
$order->total_shipping = (double) $item['total_shipping'];
$order->carrier_tax_rate = (double) Tax::getCarrierTaxRate((int) $item['id_carrier'], (int) $item[Configuration::get('PS_TAX_ADDRESS_TYPE')]);
$order->total_wrapping = (double) $item['total_wrapping'];
$order->total_paid = (double) $item['total_paid'];
$order->total_paid_real = (double) $item['total_paid_real'];
$order->invoice_date = '0000-00-00 00:00:00';
$order->delivery_date = '0000-00-00 00:00:00';
if (array_key_exists('date_add', $item)) {
$order->date_add = $item['date_add'];
}
if (array_key_exists('date_upd', $item)) {
$order->date_upd = $item['date_upd'];
}
//test valid paid
if ($item['total_paid'] == $item['total_paid_real']) {
$order->valid = 1;
} else {
$order->valid = 0;
}
$order->save(false, false);
$this->saveMatchId('order', (int) $order->id, (int) $item['id_cart']);
}
}
示例15: createOrder
//.........这里部分代码省略.........
$this->current_time_0 = time();
Toolbox::displayDebugMessage(self::getL('Cart') . ' : ' . ((int) $this->current_time_0 - (int) $this->current_time_2) . 's');
}
/* Creating order */
$id_order_temp = 0;
$order = new Order();
$order->id_carrier = Gateway::getConfig('CARRIER_NETEVEN');
$order->id_lang = Configuration::get('PS_LANG_DEFAULT');
$order->id_customer = $id_customer;
$order->id_cart = $cart->id;
$order->id_currency = Configuration::get('PS_CURRENCY_DEFAULT');
$order->id_address_delivery = $id_address_shipping;
$order->id_address_invoice = $id_address_billing;
$order->secure_key = $secure_key_default;
$order->payment = $neteven_order->PaymentMethod;
$order->conversion_rate = 1;
$order->module = 'nqgatewayneteven';
$order->recyclable = 0;
$order->gift = 0;
$order->gift_message = ' ';
$order->shipping_number = '';
/* generate reference order */
$nbr_order_neteven = Configuration::get('NUMBER_ORDER_NETEVEN');
if (false === $nbr_order_neteven) {
$nbr_order_neteven = 1;
} else {
$nbr_order_neteven = (int) str_replace('N', '', $nbr_order_neteven);
$nbr_order_neteven++;
}
$next_ref_gen_order_neteven = 'N' . sprintf('%07s', $nbr_order_neteven);
Configuration::updateValue('NUMBER_ORDER_NETEVEN', $next_ref_gen_order_neteven);
$order->reference = $next_ref_gen_order_neteven;
/* ----- */
$carrier = new Carrier((int) $order->id_carrier);
if (method_exists($carrier, 'getTaxesRate')) {
$carrier_tax_rate = $carrier->getTaxesRate(new Address($order->{Configuration::get('PS_TAX_ADDRESS_TYPE')}));
} elseif (method_exists('Tax', 'getCarrierTaxRate')) {
$carrier_tax_rate = (double) Tax::getCarrierTaxRate($order->id_carrier, (int) $order->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
} else {
$carrier_tax_rate = 100;
}
$total_shipping_tax_excl = $carrier_tax_rate ? $neteven_order->OrderShippingCost->_ / ($carrier_tax_rate / 100) : $neteven_order->OrderShippingCost->_;
$total_wt = $total_product_wt + $neteven_order->OrderShippingCost->_;
$total = $total_product + $total_shipping_tax_excl;
$order->total_discounts_tax_excl = 0;
$order->total_discounts_tax_incl = 0;
$order->total_discounts = 0;
$order->total_wrapping_tax_excl = 0;
$order->total_wrapping_tax_incl = 0;
$order->total_wrapping = 0;
$order->total_products = (double) number_format($total_product, 2, '.', '');
$order->total_products_wt = (double) number_format($total_product_wt, 2, '.', '');
$order->total_shipping_tax_excl = (double) number_format($total_shipping_tax_excl, 2, '.', '');
$order->total_shipping_tax_incl = (double) number_format($neteven_order->OrderShippingCost->_, 2, '.', '');
$order->total_shipping = (double) number_format($neteven_order->OrderShippingCost->_, 2, '.', '');
$order->total_paid_tax_excl = (double) number_format($total_wt - $total_taxe, 2, '.', '');
$order->total_paid_tax_incl = (double) number_format($total_wt, 2, '.', '');
$order->total_paid_real = (double) number_format($total_wt, 2, '.', '');
$order->total_paid = (double) number_format($total_wt, 2, '.', '');
$order->carrier_tax_rate = 0;
$order->total_wrapping = 0;
$order->invoice_number = 0;
$order->delivery_number = 0;
$order->invoice_date = $date_now;
$order->delivery_date = $date_now;
$order->valid = 1;
$order->date_add = $date_now;
$order->date_upd = $date_now;
if (Configuration::get('PS_SHOP_ENABLE')) {
$order->id_shop = (int) Configuration::get('PS_SHOP_DEFAULT');
}
if (!$order->add()) {
Toolbox::addLogLine(self::getL('Failed for order creation / NetEven Order Id') . ' ' . (int) $neteven_order->OrderID);
} else {
$id_order_temp = $order->id;
Db::getInstance()->Execute('INSERT INTO `' . _DB_PREFIX_ . 'order_carrier` (`id_order`, `id_carrier`, `id_order_invoice`, `weight`, `shipping_cost_tax_excl`, `shipping_cost_tax_incl`, `tracking_number`, `date_add`) VALUES (' . (int) $id_order_temp . ', ' . (int) Gateway::getConfig('CARRIER_NETEVEN') . ', 0, 0, 0, 0, 0,"' . pSQL(date('Y-m-d H:i:s')) . '")');
Db::getInstance()->Execute('INSERT INTO `' . _DB_PREFIX_ . 'message` (`id_order`, `message`, `date_add`) VALUES (' . (int) $id_order_temp . ', "Place de marché ' . $neteven_order->MarketPlaceName . '", "' . pSQL(date('Y-m-d H:i:s')) . '")');
Db::getInstance()->Execute('INSERT INTO `' . _DB_PREFIX_ . 'message` (`id_order`, `message`, `date_add`) VALUES (' . (int) $id_order_temp . ', "ID order NetEven ' . $neteven_order->MarketPlaceOrderId . '", "' . pSQL(date('Y-m-d H:i:s')) . '")');
if ($this->time_analyse) {
$this->current_time_2 = time();
Toolbox::displayDebugMessage(self::getL('Order') . ' : ' . ((int) $this->current_time_2 - (int) $this->current_time_0) . 's');
}
Toolbox::addLogLine(self::getL('Add order Id') . ' ' . (int) $id_order_temp . ' ' . self::getL('NetEven Order Id') . ' ' . (int) $neteven_order->OrderID);
if ($this->time_analyse) {
$this->current_time_0 = time();
Toolbox::displayDebugMessage(self::getL('History') . ' : ' . ((int) $this->current_time_0 - (int) $this->current_time_2) . 's');
}
/* Insert order in orders_gateway table */
if (!Db::getInstance()->Execute('INSERT INTO `' . _DB_PREFIX_ . 'orders_gateway` (`id_order_neteven`, `id_order`, `id_order_detail_neteven`, `date_add`, `date_upd`) VALUES (' . (int) $neteven_order->OrderID . ', ' . (int) $id_order_temp . ', 0, "' . pSQL($date_now) . '", "' . pSQL($date_now) . '")')) {
Toolbox::addLogLine(self::getL('Failed for save export NetEven order Id') . ' ' . (int) $neteven_order->OrderID);
} else {
Toolbox::addLogLine(self::getL('Save export NetEven order Id') . ' ' . (int) $neteven_order->OrderID);
}
}
} else {
$id_order_temp = $res['id_order'];
Toolbox::addLogLine(self::getL('Get already exported order Id') . ' ' . $res['id_order'] . ' ' . self::getL('NetEven Order Id') . ' ' . (int) $neteven_order->OrderID);
}
return $id_order_temp;
}