本文整理汇总了PHP中Tax::getProductTaxRate方法的典型用法代码示例。如果您正苦于以下问题:PHP Tax::getProductTaxRate方法的具体用法?PHP Tax::getProductTaxRate怎么用?PHP Tax::getProductTaxRate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tax
的用法示例。
在下文中一共展示了Tax::getProductTaxRate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _assignSummaryInformations
protected function _assignSummaryInformations()
{
$summary = $this->context->cart->getSummaryDetails();
$customizedDatas = Product::getAllCustomizedDatas($this->context->cart->id);
// override customization tax rate with real tax (tax rules)
if ($customizedDatas) {
foreach ($summary['products'] as &$productUpdate) {
$productId = (int) isset($productUpdate['id_product']) ? $productUpdate['id_product'] : $productUpdate['product_id'];
$productAttributeId = (int) isset($productUpdate['id_product_attribute']) ? $productUpdate['id_product_attribute'] : $productUpdate['product_attribute_id'];
if (isset($customizedDatas[$productId][$productAttributeId])) {
$productUpdate['tax_rate'] = Tax::getProductTaxRate($productId, $this->context->cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
}
}
Product::addCustomizationPrice($summary['products'], $customizedDatas);
}
$cart_product_context = Context::getContext()->cloneContext();
foreach ($summary['products'] as $key => &$product) {
$product['quantity'] = $product['cart_quantity'];
// for compatibility with 1.2 themes
if ($cart_product_context->shop->id != $product['id_shop']) {
$cart_product_context->shop = new Shop((int) $product['id_shop']);
}
$product['price_without_specific_price'] = Product::getPriceStatic($product['id_product'], !Product::getTaxCalculationMethod(), $product['id_product_attribute'], _PS_PRICE_COMPUTE_PRECISION_, null, false, false, 1, false, null, null, null, $null, true, true, $cart_product_context);
/**
* ABU edit: variable is_discount set à 1 à tord, calcul foireux de presta
* @bugfix: https://github.com/PrestaShop/PrestaShop/commit/379e28b341730ea95c0b2d6567817305ea841b23
* @perso: soustraction de l'ecotax au price_without_specific_price @else
*/
if (Product::getTaxCalculationMethod()) {
// $product['is_discounted'] = $product['price_without_specific_price'] != Tools::ps_round($product['price'], _PS_PRICE_COMPUTE_PRECISION_);
$product['is_discounted'] = Tools::ps_round($product['price_without_specific_price'], _PS_PRICE_COMPUTE_PRECISION_) != Tools::ps_round($product['price'], _PS_PRICE_COMPUTE_PRECISION_);
} else {
// $product['is_discounted'] = $product['price_without_specific_price'] != Tools::ps_round($product['price_wt'], _PS_PRICE_COMPUTE_PRECISION_);
$product['is_discounted'] = Tools::ps_round($product['price_without_specific_price'] - $product['ecotax'], _PS_PRICE_COMPUTE_PRECISION_) != Tools::ps_round($product['price_wt'], _PS_PRICE_COMPUTE_PRECISION_);
}
}
// Get available cart rules and unset the cart rules already in the cart
$available_cart_rules = CartRule::getCustomerCartRules($this->context->language->id, isset($this->context->customer->id) ? $this->context->customer->id : 0, true, true, true, $this->context->cart);
$cart_cart_rules = $this->context->cart->getCartRules();
foreach ($available_cart_rules as $key => $available_cart_rule) {
if (!$available_cart_rule['highlight'] || strpos($available_cart_rule['code'], CartRule::BO_ORDER_CODE_PREFIX) === 0) {
unset($available_cart_rules[$key]);
continue;
}
foreach ($cart_cart_rules as $cart_cart_rule) {
if ($available_cart_rule['id_cart_rule'] == $cart_cart_rule['id_cart_rule']) {
unset($available_cart_rules[$key]);
continue 2;
}
}
}
$show_option_allow_separate_package = !$this->context->cart->isAllProductsInStock(true) && Configuration::get('PS_SHIP_WHEN_AVAILABLE');
$this->context->smarty->assign($summary);
$this->context->smarty->assign(array('token_cart' => Tools::getToken(false), 'isLogged' => $this->isLogged, 'isVirtualCart' => $this->context->cart->isVirtualCart(), 'productNumber' => $this->context->cart->nbProducts(), 'voucherAllowed' => CartRule::isFeatureActive(), 'shippingCost' => $this->context->cart->getOrderTotal(true, Cart::ONLY_SHIPPING), 'shippingCostTaxExc' => $this->context->cart->getOrderTotal(false, Cart::ONLY_SHIPPING), 'customizedDatas' => $customizedDatas, 'CUSTOMIZE_FILE' => Product::CUSTOMIZE_FILE, 'CUSTOMIZE_TEXTFIELD' => Product::CUSTOMIZE_TEXTFIELD, 'lastProductAdded' => $this->context->cart->getLastProduct(), 'displayVouchers' => $available_cart_rules, 'show_option_allow_separate_package' => $show_option_allow_separate_package, 'smallSize' => Image::getSize(ImageType::getFormatedName('small'))));
$this->context->smarty->assign(array('HOOK_SHOPPING_CART' => Hook::exec('displayShoppingCartFooter', $summary), 'HOOK_SHOPPING_CART_EXTRA' => Hook::exec('displayShoppingCart', $summary)));
}
示例2: array
$minimum_surface = (double) DB::getInstance()->getValue('SELECT aimd_msc FROM ' . _DB_PREFIX_ . 'product WHERE id_product = ' . $product_id);
// Minimum surface to charge
$global_reduction = Configuration::get('AIMD_GLOBAL_REDUCTION');
// Global reduction
// Get customer group taxes rules & global taxes rules
$group_id = 1;
if (isset($cookie->id_customer)) {
$group_id = Customer::getDefaultGroupId($cookie->id_customer);
}
if (intval(Group::getDefaultPriceDisplayMethod($group_id)) == 1 || !Configuration::get('PS_TAX')) {
$taxes = 1;
// Taxes rate
$base_price = Product::getPriceStatic($product_id, false, false, 6, NULL, false, false);
// Product price without taxes & without attributes
} else {
$taxes = 1 + Tax::getProductTaxRate($product_id) / 100;
// Taxes rate
$base_price = Product::getPriceStatic($product_id, true, false, 6, NULL, false, false);
// Product price with taxes & without attributes
}
// Get the multi-dimensionnal parameters
$dimensions = array();
$scales = array();
if (Configuration::get('AIMD_FIRST_DIMENSION_ACTIVE') == 1) {
$dimensions[] = Configuration::get('AIMD_FIRST_DIMENSION_ID');
$scales[Configuration::get('AIMD_FIRST_DIMENSION_ID')] = Configuration::get('AIMD_FIRST_DIMENSION_SCALE');
}
if (Configuration::get('AIMD_SECOND_DIMENSION_ACTIVE') == 1) {
$dimensions[] = Configuration::get('AIMD_SECOND_DIMENSION_ID');
$scales[Configuration::get('AIMD_SECOND_DIMENSION_ID')] = Configuration::get('AIMD_SECOND_DIMENSION_SCALE');
}
示例3: getDataByProductId
public static function getDataByProductId($id_product)
{
Tools::displayAsDeprecated();
$tax_rate = Tax::getProductTaxRate((int) $id_product);
$id_tax = Tax::getTaxIdByRate($tax_rate);
return array('id_tax' => $id_tax, 'rate' => $tax_rate);
}
示例4: validateOrder
//.........这里部分代码省略.........
Product::addCustomizationPrice($products, $customizedDatas);
$outOfStock = false;
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 != _PS_OS_CANCELED_ and $id_order_state != _PS_OS_ERROR_) {
if (Product::updateQuantity($product, (int) $order->id)) {
$product['stock_quantity'] -= $product['cart_quantity'];
}
if ($product['stock_quantity'] < 0 && Configuration::get('PS_STOCK_MANAGEMENT')) {
$outOfStock = true;
}
if ($product['stock_quantity'] < 1) {
SolrSearch::updateProduct((int) $product['id_product']);
}
Product::updateDefaultAttribute($product['id_product']);
}
$price = Product::getPriceStatic((int) $product['id_product'], false, $product['id_product_attribute'] ? (int) $product['id_product_attribute'] : NULL, 6, NULL, false, true, $product['cart_quantity'], false, (int) $order->id_customer, (int) $order->id_cart, (int) $order->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
$price_wt = Product::getPriceStatic((int) $product['id_product'], true, $product['id_product_attribute'] ? (int) $product['id_product_attribute'] : NULL, 2, NULL, false, true, $product['cart_quantity'], false, (int) $order->id_customer, (int) $order->id_cart, (int) $order->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
// Add some informations for virtual products
$deadline = '0000-00-00 00:00:00';
$download_hash = NULL;
if ($id_product_download = ProductDownload::getIdFromIdProduct((int) $product['id_product'])) {
$productDownload = new ProductDownload((int) $id_product_download);
$deadline = $productDownload->getDeadLine();
$download_hash = $productDownload->getHash();
}
// Exclude VAT
if (Tax::excludeTaxeOption()) {
$product['tax'] = 0;
$product['rate'] = 0;
$tax_rate = 0;
} else {
$tax_rate = Tax::getProductTaxRate((int) $product['id_product'], $cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
}
$ecotaxTaxRate = 0;
if (!empty($product['ecotax'])) {
$ecotaxTaxRate = Tax::getProductEcotaxRate($order->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
}
$quantityDiscount = SpecificPrice::getQuantityDiscount((int) $product['id_product'], Shop::getCurrentShop(), (int) $cart->id_currency, (int) $vat_address->id_country, (int) $customer->id_default_group, (int) $product['cart_quantity']);
$unitPrice = Product::getPriceStatic((int) $product['id_product'], true, $product['id_product_attribute'] ? intval($product['id_product_attribute']) : NULL, 2, NULL, false, true, 1, false, (int) $order->id_customer, NULL, (int) $order->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
$quantityDiscountValue = $quantityDiscount ? (Product::getTaxCalculationMethod((int) $order->id_customer) == PS_TAX_EXC ? Tools::ps_round($unitPrice, 2) : $unitPrice) - $quantityDiscount['price'] * (1 + $tax_rate / 100) : 0.0;
$specificPrice = 0;
$query .= '(' . (int) $order->id . ',
' . (int) $product['id_product'] . ',
' . (isset($product['id_product_attribute']) ? (int) $product['id_product_attribute'] : 'NULL') . ',
\'' . pSQL($product['name'] . ((isset($product['attributes']) and $product['attributes'] != NULL) ? ' - ' . $product['attributes'] : '')) . '\',
' . (int) $product['cart_quantity'] . ',
' . $quantityInStock . ',
' . (double) Product::getPriceStatic((int) $product['id_product'], false, $product['id_product_attribute'] ? (int) $product['id_product_attribute'] : NULL, Product::getTaxCalculationMethod((int) $order->id_customer) == PS_TAX_EXC ? 2 : 6, NULL, false, false, $product['cart_quantity'], false, (int) $order->id_customer, (int) $order->id_cart, (int) $order->{Configuration::get('PS_TAX_ADDRESS_TYPE')}, $specificPrice, FALSE) . ',
' . (double) (($specificPrice and $specificPrice['reduction_type'] == 'percentage') ? $specificPrice['reduction'] * 100 : 0.0) . ',
' . (double) (($specificPrice and $specificPrice['reduction_type'] == 'amount') ? !$specificPrice['id_currency'] ? Tools::convertPrice($specificPrice['reduction'], $order->id_currency) : $specificPrice['reduction'] : 0.0) . ',
' . (double) Group::getReduction((int) $order->id_customer) . ',
' . $quantityDiscountValue . ',
' . (empty($product['ean13']) ? 'NULL' : '\'' . pSQL($product['ean13']) . '\'') . ',
' . (empty($product['upc']) ? 'NULL' : '\'' . pSQL($product['upc']) . '\'') . ',
' . (empty($product['reference']) ? 'NULL' : '\'' . pSQL($product['reference']) . '\'') . ',
' . (empty($product['supplier_reference']) ? 'NULL' : '\'' . pSQL($product['supplier_reference']) . '\'') . ',
' . (double) ($product['id_product_attribute'] ? $product['weight_attribute'] : $product['weight']) . ',
\'' . (empty($tax_rate) ? '' : pSQL($product['tax'])) . '\',
' . (double) $tax_rate . ',
' . (double) Tools::convertPrice(floatval($product['ecotax']), intval($order->id_currency)) . ',
' . (double) $ecotaxTaxRate . ',
' . (($specificPrice and $specificPrice['from_quantity'] > 1) ? 1 : 0) . ',
\'' . pSQL($deadline) . '\',
\'' . pSQL($download_hash) . '\', ' . $cart->getProductCustomizationCost($product['id_product']) . '),';
示例5: _assignSummaryInformations
protected function _assignSummaryInformations()
{
$summary = $this->context->cart->getSummaryDetails();
$customizedDatas = Product::getAllCustomizedDatas($this->context->cart->id);
// override customization tax rate with real tax (tax rules)
if ($customizedDatas) {
foreach ($summary['products'] as &$productUpdate) {
$productId = (int) (isset($productUpdate['id_product']) ? $productUpdate['id_product'] : $productUpdate['product_id']);
$productAttributeId = (int) (isset($productUpdate['id_product_attribute']) ? $productUpdate['id_product_attribute'] : $productUpdate['product_attribute_id']);
if (isset($customizedDatas[$productId][$productAttributeId])) {
$productUpdate['tax_rate'] = Tax::getProductTaxRate($productId, $this->context->cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
}
}
Product::addCustomizationPrice($summary['products'], $customizedDatas);
}
$cart_product_context = Context::getContext()->cloneContext();
foreach ($summary['products'] as $key => &$product) {
$product['quantity'] = $product['cart_quantity'];
// for compatibility with 1.2 themes
if ($cart_product_context->shop->id != $product['id_shop']) {
$cart_product_context->shop = new Shop((int) $product['id_shop']);
}
$product['price_without_specific_price'] = Product::getPriceStatic($product['id_product'], !Product::getTaxCalculationMethod(), $product['id_product_attribute'], 2, null, false, false, 1, false, null, null, null, $null, true, true, $cart_product_context);
if (Product::getTaxCalculationMethod()) {
$product['is_discounted'] = $product['price_without_specific_price'] != $product['price'];
} else {
$product['is_discounted'] = $product['price_without_specific_price'] != $product['price_wt'];
}
}
// Get available cart rules and unset the cart rules already in the cart
$available_cart_rules = CartRule::getCustomerCartRules($this->context->language->id, isset($this->context->customer->id) ? $this->context->customer->id : 0, true, true, true, $this->context->cart);
$cart_cart_rules = $this->context->cart->getCartRules();
foreach ($available_cart_rules as $key => $available_cart_rule) {
if (!$available_cart_rule['highlight'] || strpos($available_cart_rule['code'], 'BO_ORDER_') === 0) {
unset($available_cart_rules[$key]);
continue;
}
foreach ($cart_cart_rules as $cart_cart_rule) {
if ($available_cart_rule['id_cart_rule'] == $cart_cart_rule['id_cart_rule']) {
unset($available_cart_rules[$key]);
continue 2;
}
}
}
$show_option_allow_separate_package = !$this->context->cart->isAllProductsInStock(true) && Configuration::get('PS_SHIP_WHEN_AVAILABLE');
$this->context->smarty->assign($summary);
$this->context->smarty->assign(array('token_cart' => Tools::getToken(false), 'isLogged' => $this->isLogged, 'isVirtualCart' => $this->context->cart->isVirtualCart(), 'productNumber' => $this->context->cart->nbProducts(), 'voucherAllowed' => CartRule::isFeatureActive(), 'shippingCost' => $this->context->cart->getOrderTotal(true, Cart::ONLY_SHIPPING), 'shippingCostTaxExc' => $this->context->cart->getOrderTotal(false, Cart::ONLY_SHIPPING), 'customizedDatas' => $customizedDatas, 'CUSTOMIZE_FILE' => Product::CUSTOMIZE_FILE, 'CUSTOMIZE_TEXTFIELD' => Product::CUSTOMIZE_TEXTFIELD, 'lastProductAdded' => $this->context->cart->getLastProduct(), 'displayVouchers' => $available_cart_rules, 'currencySign' => $this->context->currency->sign, 'currencyRate' => $this->context->currency->conversion_rate, 'currencyFormat' => $this->context->currency->format, 'currencyBlank' => $this->context->currency->blank, 'show_option_allow_separate_package' => $show_option_allow_separate_package, 'smallSize' => Image::getSize(ImageType::getFormatedName('small'))));
$this->context->smarty->assign(array('HOOK_SHOPPING_CART' => Hook::exec('displayShoppingCartFooter', $summary), 'HOOK_SHOPPING_CART_EXTRA' => Hook::exec('displayShoppingCart', $summary)));
}
示例6: getOrderTotal
/**
* This function returns the total cart amount
*
* Possible values for $type:
* Cart::ONLY_PRODUCTS
* Cart::ONLY_DISCOUNTS
* Cart::BOTH
* Cart::BOTH_WITHOUT_SHIPPING
* Cart::ONLY_SHIPPING
* Cart::ONLY_WRAPPING
* Cart::ONLY_PRODUCTS_WITHOUT_SHIPPING
*
* @param boolean $withTaxes With or without taxes
* @param integer $type Total type
* @return float Order total
*/
public function getOrderTotal($withTaxes = true, $type = Cart::BOTH)
{
if (!$this->id) {
return 0;
}
$type = (int) $type;
if (!in_array($type, array(Cart::ONLY_PRODUCTS, Cart::ONLY_DISCOUNTS, Cart::BOTH, Cart::BOTH_WITHOUT_SHIPPING, Cart::ONLY_SHIPPING, Cart::ONLY_WRAPPING, Cart::ONLY_PRODUCTS_WITHOUT_SHIPPING))) {
die(Tools::displayError());
}
// no shipping cost if is a cart with only virtuals products
$virtual = $this->isVirtualCart();
if ($virtual and $type == Cart::ONLY_SHIPPING) {
return 0;
}
if ($virtual and $type == Cart::BOTH) {
$type = Cart::BOTH_WITHOUT_SHIPPING;
}
$shipping_fees = ($type != Cart::BOTH_WITHOUT_SHIPPING and $type != Cart::ONLY_PRODUCTS_WITHOUT_SHIPPING) ? $this->getOrderShippingCost(NULL, (int) $withTaxes) : 0;
if ($type == Cart::ONLY_PRODUCTS_WITHOUT_SHIPPING) {
$type = Cart::ONLY_PRODUCTS;
}
$products = $this->getProducts();
$order_total = 0;
if (Tax::excludeTaxeOption()) {
$withTaxes = false;
}
foreach ($products as $product) {
if ($this->_taxCalculationMethod == PS_TAX_EXC) {
// Here taxes are computed only once the quantity has been applied to the product price
$price = Product::getPriceStatic((int) $product['id_product'], false, (int) $product['id_product_attribute'], 2, NULL, false, true, $product['cart_quantity'], false, (int) $this->id_customer ? (int) $this->id_customer : NULL, (int) $this->id, $this->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
$total_ecotax = $product['ecotax'] * (int) $product['cart_quantity'];
$total_price = $price * (int) $product['cart_quantity'];
if ($withTaxes) {
$total_price = ($total_price - $total_ecotax) * (1 + (double) Tax::getProductTaxRate((int) $product['id_product'], (int) $this->{Configuration::get('PS_TAX_ADDRESS_TYPE')}) / 100);
$total_ecotax = $total_ecotax * (1 + Tax::getProductEcotaxRate((int) $this->{Configuration::get('PS_TAX_ADDRESS_TYPE')}) / 100);
$total_price = Tools::ps_round($total_price + $total_ecotax, 2);
}
} else {
$price = Product::getPriceStatic((int) $product['id_product'], true, (int) $product['id_product_attribute'], 2, NULL, false, true, $product['cart_quantity'], false, (int) $this->id_customer ? (int) $this->id_customer : NULL, (int) $this->id, (int) $this->{Configuration::get('PS_TAX_ADDRESS_TYPE')} ? (int) $this->{Configuration::get('PS_TAX_ADDRESS_TYPE')} : NULL);
$total_price = Tools::ps_round($price, 2) * (int) $product['cart_quantity'];
if (!$withTaxes) {
$total_price = Tools::ps_round($total_price / (1 + (double) Tax::getProductTaxRate((int) $product['id_product'], (int) $this->{Configuration::get('PS_TAX_ADDRESS_TYPE')}) / 100), 2);
}
}
$order_total += $total_price;
}
$order_total_products = $order_total;
if ($type == Cart::ONLY_DISCOUNTS) {
$order_total = 0;
}
// Wrapping Fees
$wrapping_fees = 0;
if ($this->gift) {
$wrapping_fees = (double) Configuration::get('PS_GIFT_WRAPPING_PRICE');
if ($withTaxes) {
$wrapping_fees_tax = new Tax((int) Configuration::get('PS_GIFT_WRAPPING_TAX'));
$wrapping_fees *= 1 + (double) $wrapping_fees_tax->rate / 100;
}
$wrapping_fees = Tools::convertPrice(Tools::ps_round($wrapping_fees, 2), Currency::getCurrencyInstance((int) $this->id_currency));
}
if ($type != Cart::ONLY_PRODUCTS) {
$discounts = array();
/* Firstly get all discounts, looking for a free shipping one (in order to substract shipping fees to the total amount) */
if ($discountIds = $this->getDiscounts(true)) {
foreach ($discountIds as $id_discount) {
$discount = new Discount((int) $id_discount['id_discount']);
if (Validate::isLoadedObject($discount)) {
$discounts[] = $discount;
if ($discount->id_discount_type == 3) {
foreach ($products as $product) {
$categories = Discount::getCategories($discount->id);
if (count($categories) and Product::idIsOnCategoryId($product['id_product'], $categories)) {
if ($type == Cart::ONLY_DISCOUNTS) {
$order_total -= $shipping_fees;
}
$shipping_fees = 0;
break;
}
}
}
}
}
/* Secondly applying all vouchers to the correct amount */
$shrunk = false;
//.........这里部分代码省略.........
示例7: __construct
public function __construct($id_product = NULL, $full = false, $id_lang = NULL, $from_cache = TRUE)
{
global $cart;
parent::__construct($id_product, $id_lang, $from_cache);
if ($full and $this->id) {
$this->tax_name = 'deprecated';
// The applicable tax may be BOTH the product one AND the state one (moreover this variable is some deadcode)
$this->manufacturer_name = Manufacturer::getNameById((int) $this->id_manufacturer);
$this->supplier_name = Supplier::getNameById((int) $this->id_supplier);
self::$_tax_rules_group[$this->id] = $this->id_tax_rules_group;
if (is_object($cart) and $cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')} != NULL) {
$this->tax_rate = Tax::getProductTaxRate($this->id, $cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
} else {
$this->tax_rate = Tax::getProductTaxRate($this->id, NULL);
}
$this->new = $this->isNew();
$this->price = Product::getPriceStatic((int) $this->id, false, NULL, 6, NULL, false, true, 1, false, NULL, NULL, NULL, $this->specificPrice);
$this->unit_price = $this->unit_price_ratio != 0 ? $this->price / $this->unit_price_ratio : 0;
if ($this->id) {
$this->tags = Tag::getProductTags((int) $this->id);
}
$features = $this->getFrontFeatures($id_lang);
foreach ($features as $row) {
if ($row['id_feature'] == 1) {
$this->fabric = $row['value'];
}
if ($row['id_feature'] == 2) {
$this->color = $row['value'];
}
if ($row['id_feature'] == 3) {
$this->garment_type = $row['value'];
}
if ($row['id_feature'] == 4) {
$this->work_type = $row['value'];
}
if ($row['id_feature'] == 5) {
$this->blouse_length = $row['value'];
}
if ($row['id_feature'] == 6) {
$this->wash_care = $row['value'];
}
if ($row['id_feature'] == 7) {
$this->other_info = $row['value'];
}
if ($row['id_feature'] == 8) {
$this->shipping_estimate = $row['value'];
$this->shipping_sla = (int) preg_replace('/\\D/', '', $this->shipping_estimate);
}
if ($row['id_feature'] == 9) {
$this->kameez_style = $row['value'];
}
if ($row['id_feature'] == 10) {
$this->salwar_style = $row['value'];
}
if ($row['id_feature'] == 11) {
$this->sleeves = $row['value'];
}
if ($row['id_feature'] == 12) {
$this->generic_color = $row['value'];
}
if ($row['id_feature'] == 13) {
$this->skirt_length = $row['value'];
}
if ($row['id_feature'] == 14) {
$this->dupatta_length = $row['value'];
}
if ($row['id_feature'] == 15) {
$this->stone = $row['value'];
}
if ($row['id_feature'] == 16) {
$this->plating = $row['value'];
}
if ($row['id_feature'] == 17) {
$this->material = $row['value'];
}
if ($row['id_feature'] == 18) {
$this->dimensions = $row['value'];
}
if ($row['id_feature'] == 19) {
$this->look = $row['value'];
}
if ($row['id_feature'] == 21) {
$this->handbag_occasion = $row['value'];
}
if ($row['id_feature'] == 22) {
$this->handbag_style = $row['value'];
}
if ($row['id_feature'] == 23) {
$this->handbag_material = $row['value'];
}
}
}
if ($this->id_category_default) {
$this->category = Category::getLinkRewrite((int) $this->id_category_default, (int) $id_lang);
}
}
示例8: _assignSummaryInformations
protected function _assignSummaryInformations()
{
$summary = $this->context->cart->getSummaryDetails();
$customizedDatas = Product::getAllCustomizedDatas($this->context->cart->id);
// override customization tax rate with real tax (tax rules)
if ($customizedDatas) {
foreach ($summary['products'] as &$productUpdate) {
$productId = (int) (isset($productUpdate['id_product']) ? $productUpdate['id_product'] : $productUpdate['product_id']);
$productAttributeId = (int) (isset($productUpdate['id_product_attribute']) ? $productUpdate['id_product_attribute'] : $productUpdate['product_attribute_id']);
if (isset($customizedDatas[$productId][$productAttributeId])) {
$productUpdate['tax_rate'] = Tax::getProductTaxRate($productId, $this->context->cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
}
}
Product::addCustomizationPrice($summary['products'], $customizedDatas);
}
foreach ($summary['products'] as $key => &$product) {
$product['quantity'] = $product['cart_quantity'];
// for compatibility with 1.2 themes
$product['price_without_specific_price'] = Product::getPriceStatic($product['id_product'], !Product::getTaxCalculationMethod(), $product['id_product_attribute'], 2, null, false, false);
if (Product::getTaxCalculationMethod()) {
$product['is_discounted'] = $product['price_without_specific_price'] != $product['price'];
} else {
$product['is_discounted'] = $product['price_without_specific_price'] != $product['price_wt'];
}
}
$show_option_allow_separate_package = !$this->context->cart->isAllProductsInStock(true) && Configuration::get('PS_SHIP_WHEN_AVAILABLE');
$this->context->smarty->assign($summary);
$this->context->smarty->assign(array('token_cart' => Tools::getToken(false), 'isVirtualCart' => $this->context->cart->isVirtualCart(), 'productNumber' => $this->context->cart->nbProducts(), 'voucherAllowed' => Configuration::get('PS_VOUCHERS') && CartRule::isFeatureActive(), 'shippingCost' => $this->context->cart->getOrderTotal(true, Cart::ONLY_SHIPPING), 'shippingCostTaxExc' => $this->context->cart->getOrderTotal(false, Cart::ONLY_SHIPPING), 'customizedDatas' => $customizedDatas, 'CUSTOMIZE_FILE' => Product::CUSTOMIZE_FILE, 'CUSTOMIZE_TEXTFIELD' => Product::CUSTOMIZE_TEXTFIELD, 'lastProductAdded' => $this->context->cart->getLastProduct(), 'displayVouchers' => Discount::getVouchersToCartDisplay($this->context->language->id, isset($this->context->customer->id) ? $this->context->customer->id : 0), 'currencySign' => $this->context->currency->sign, 'currencyRate' => $this->context->currency->conversion_rate, 'currencyFormat' => $this->context->currency->format, 'currencyBlank' => $this->context->currency->blank, 'show_option_allow_separate_package' => $show_option_allow_separate_package));
$this->context->smarty->assign(array('HOOK_SHOPPING_CART' => Hook::exec('displayShoppingCartFooter', $summary), 'HOOK_SHOPPING_CART_EXTRA' => Hook::exec('displayShoppingCart', $summary)));
}
示例9: postProcess
//.........这里部分代码省略.........
$freeShipVoucher->quantity_per_user = 1;
$freeShipVoucher->value = 0;
$freeShipVoucher->add(true);
$cart->addDiscount($freeShipVoucher->id);
$order->addDiscount($freeShipVoucher->id, $freeShipVoucher->name, $freeShipVoucher->value);
$cart->update();
$update = true;
}
$id_product = false;
if ($id_product = Tools::getValue('addProductID')) {
$product = new Product((int) $id_product, true, (int) $cookie->id_lang);
if ($product->quantity > 0 && $product->available_for_order) {
$cart->updateQty(1, $id_product);
}
$orderDetail = null;
$db = Db::getInstance();
$res = $db->getRow('select id_order_detail from ps_order_detail where id_order = ' . $order->id . ' and product_id = ' . $id_product);
$vat_address = new Address((int) $order->id_address_delivery);
$customer = new Customer((int) $order->id_customer);
$unitPrice = Product::getPriceStatic((int) $id_product, true, NULL, 2, NULL, false, true, 1, false, (int) $order->id_customer, NULL, (int) $order->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
if ($res) {
$orderDetail = new OrderDetail($res['id_order_detail']);
$orderDetail->product_quantity = $orderDetail->product_quantity + 1;
} else {
$productName = $product->name;
$orderDetail = new OrderDetail();
$orderDetail->product_quantity = 1;
$orderDetail->id_order = $order->id;
$orderDetail->product_id = $id_product;
$orderDetail->product_name = $productName;
$orderDetail->product_ean13 = $product->ean13;
$price = Product::getPriceStatic($id_product, false, NULL, 6, NULL, false, true, $orderDetail->product_quantity, false, (int) $order->id_customer, (int) $order->id_cart, (int) $order->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
$price_wt = Product::getPriceStatic((int) $id_product, true, NULL, 2, NULL, false, true, $orderDetail->product_quantity, false, (int) $order->id_customer, (int) $order->id_cart, (int) $order->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
$tax_rate = Tax::getProductTaxRate((int) $id_product, $cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
$specificPrice = 0;
$quantityDiscount = SpecificPrice::getQuantityDiscount((int) $id_product, Shop::getCurrentShop(), (int) $cart->id_currency, (int) $vat_address->id_country, (int) $customer->id_default_group, $orderDetail->product_quantity);
$orderDetail->product_price = (double) Product::getPriceStatic((int) $id_product, false, NULL, Product::getTaxCalculationMethod((int) $order->id_customer) == PS_TAX_EXC ? 2 : 6, NULL, false, false, $orderDetail->product_quantity, false, (int) $order->id_customer, (int) $order->id_cart, (int) $order->{Configuration::get('PS_TAX_ADDRESS_TYPE')}, $specificPrice, FALSE);
$orderDetail->product_quantity_discount = $quantityDiscount ? (Product::getTaxCalculationMethod((int) $order->id_customer) == PS_TAX_EXC ? Tools::ps_round($unitPrice, 2) : $unitPrice) - $quantityDiscount['price'] * (1 + $tax_rate / 100) : 0.0;
$orderDetail->reduction_percent = (double) (($specificPrice and $specificPrice['reduction_type'] == 'percentage') ? $specificPrice['reduction'] * 100 : 0.0);
$orderDetail->reduction_percent = (double) (($specificPrice and $specificPrice['reduction_type'] == 'amount') ? !$specificPrice['id_currency'] ? Tools::convertPrice($specificPrice['reduction'], $order->id_currency) : $specificPrice['reduction'] : 0.0);
$orderDetail->tax_rate = $tax_rate;
$orderDetail->tax_name = 'default_tax';
$orderDetail->group_reduction = 0;
$orderDetail->product_quantity_in_stock = (int) Product::getQuantity((int) $id_product, NULL);
$orderDetail->product_quantity_refunded = 0;
$orderDetail->product_quantity_reinjected = 0;
$orderDetail->ecotax = 0;
$orderDetail->ecotax_tax_rate = 0;
$orderDetail->discount_quantity_applied = 0;
$orderDetail->add(true, true);
}
$price = Product::getPriceStatic($id_product, false, NULL, 6, NULL, false, true, $orderDetail->product_quantity, false, (int) $order->id_customer, (int) $order->id_cart, (int) $order->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
$price_wt = Product::getPriceStatic((int) $id_product, true, NULL, 2, NULL, false, true, $orderDetail->product_quantity, false, (int) $order->id_customer, (int) $order->id_cart, (int) $order->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
$tax_rate = Tax::getProductTaxRate((int) $id_product, $cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
$quantityDiscount = SpecificPrice::getQuantityDiscount((int) $id_product, Shop::getCurrentShop(), (int) $cart->id_currency, (int) $vat_address->id_country, (int) $customer->id_default_group, $orderDetail->product_quantity);
$orderDetail->product_price = (double) Product::getPriceStatic((int) $id_product, false, NULL, Product::getTaxCalculationMethod((int) $order->id_customer) == PS_TAX_EXC ? 2 : 6, NULL, false, false, $orderDetail->product_quantity, false, (int) $order->id_customer, (int) $order->id_cart, (int) $order->{Configuration::get('PS_TAX_ADDRESS_TYPE')}, $specificPrice, FALSE);
$orderDetail->product_quantity_discount = $quantityDiscount ? (Product::getTaxCalculationMethod((int) $order->id_customer) == PS_TAX_EXC ? Tools::ps_round($unitPrice, 2) : $unitPrice) - $quantityDiscount['price'] * (1 + $tax_rate / 100) : 0.0;
$orderDetail->reduction_percent = (double) (($specificPrice and $specificPrice['reduction_type'] == 'percentage') ? $specificPrice['reduction'] * 100 : 0.0);
$orderDetail->reduction_amount = (double) (($specificPrice and $specificPrice['reduction_type'] == 'amount') ? !$specificPrice['id_currency'] ? Tools::convertPrice($specificPrice['reduction'], $order->id_currency) : $specificPrice['reduction'] : 0.0);
$orderDetail->update();
$product->addStockMvt(-1, _STOCK_MOVEMENT_ORDER_REASON_, NULL, $order->id, (int) $cookie->id_employee);
$update = true;
}
if ($update) {
//Recalculate product prices with and without tax from order detail
$detailIds = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('
示例10: getDataGeneration
public function getDataGeneration()
{
$datas = array();
$order_to_change_state = array();
$saved_product = array();
$datas_quantity = array();
$customer_concerned = array();
$concerned_id_order_detail = array();
$orders = Db::getInstance()->executeS('
SELECT a.id_order
FROM `' . _DB_PREFIX_ . 'orders` a
LEFT JOIN `' . _DB_PREFIX_ . 'customer` c ON (c.`id_customer` = a.`id_customer`)
WHERE a.current_state = ' . (int) $this->generate_order_state . '
ORDER BY a.`id_order` DESC');
$unselected_orders_array = array();
/* if (isset( $this->context->cookie->unselected_orders) && !empty( $this->context->cookie->unselected_orders))
{
$unselected_orders_array = Tools::unSerialize( $this->context->cookie->unselected_orders);
} */
if (Tools::getValue('unselected_orders_list', false)) {
$unselected_orders_array = explode(',', Tools::getValue('unselected_orders_list'));
$unselected_orders_array = array_map('trim', $unselected_orders_array);
}
if (!empty($orders)) {
foreach ($orders as $order) {
$id_order = (int) $order['id_order'];
if (!in_array($id_order, $unselected_orders_array)) {
$order = new Order((int) $id_order);
if (!Validate::isLoadedObject($order)) {
throw new PrestaShopException('object oder simulate can\'t be loaded');
}
$order_details = $order->getOrderDetailList();
if (!empty($order_details)) {
$order_to_change_state[] = (int) $id_order;
foreach ($order_details as $order_detail) {
$id_supplier = 0;
$product_key = $order_detail['product_id'] . '_' . $order_detail['product_attribute_id'];
$product = new Product($order_detail['product_id'], $order_detail['product_attribute_id']);
// update selling price to purchase price
$order_detail['unit_price_tax_excl'] = ErpStock::getWholesalePrice($order_detail['product_id'], $order_detail['product_attribute_id']);
$order_detail['tax_rate'] = Tax::getProductTaxRate($order_detail['product_id']);
$order_detail['unit_price_tax_incl'] = $order_detail['unit_price_tax_excl'] * (1 + (double) $order_detail['tax_rate'] / 100);
if (empty($product->id_supplier)) {
// Get already associated suppliers
$associated_suppliers = new Collection('ProductSupplierCore');
$associated_suppliers->where('id_product', '=', (int) $product->id);
$associated_suppliers->groupBy('id_supplier');
foreach ($associated_suppliers as $associated_supplier) {
$id_supplier = $associated_supplier->id_supplier;
}
} else {
$id_supplier = $product->id_supplier;
}
if (isset($saved_product[$product_key])) {
$datas_quantity[$product_key] += $order_detail['product_quantity'];
$customer_concerned[$product_key][] = $order->id_customer;
$concerned_id_order_detail[$product_key][] = array('id_order_detail' => $order_detail['id_order_detail'], 'id_customer' => $order->id_customer);
$order_detail['total_product_quantity'] = $datas_quantity[$product_key];
$order_detail['customer_concerned'] = $customer_concerned[$product_key];
$order_detail['concerned_id_order_detail'] = $concerned_id_order_detail[$product_key];
$datas[$id_supplier][$product_key] = $order_detail;
} else {
$product_quantity = $order_detail['product_quantity'];
$order_detail['total_product_quantity'] = $product_quantity;
$order_detail['customer_concerned'][] = $order->id_customer;
$order_detail['concerned_id_order_detail'][] = array('id_order_detail' => $order_detail['id_order_detail'], 'id_customer' => $order->id_customer);
$datas[$id_supplier][$product_key] = $order_detail;
$datas_quantity[$product_key] = $product_quantity;
$customer_concerned[$product_key][] = $order->id_customer;
$concerned_id_order_detail[$product_key][] = array('id_order_detail' => $order_detail['id_order_detail'], 'id_customer' => $order->id_customer);
$saved_product[$product_key] = true;
}
}
}
}
}
}
$data_return = array();
foreach ($datas as $id_supplier => $data) {
if ($id_supplier > 0) {
$product_list = array();
foreach ($data as $product_key => $product_info) {
$customer_concerned = '';
$customer_concerned_arr = array_unique($product_info['customer_concerned']);
foreach ($customer_concerned_arr as $id_customer) {
$customer = new Customer($id_customer);
$customer_concerned .= $customer->lastname . ' ' . $customer->firstname . ', ';
}
$total_te = $product_info['unit_price_tax_excl'] * $product_info['total_product_quantity'];
$total_ti = $product_info['unit_price_tax_incl'] * $product_info['total_product_quantity'];
$product_info['total_price_tax_excl'] = Tools::displayPrice($total_te);
$product_info['total_price_tax_incl'] = Tools::displayPrice($total_ti);
$product_info['unit_price_tax_excl'] = $product_info['unit_price_tax_excl'];
$product_info['customer_concerned'] = Tools::substr($customer_concerned, 0, Tools::strlen($customer_concerned) - 2);
$product_info['customer_id'] = $customer_concerned_arr;
$product_list[] = $product_info;
}
$data_return[$id_supplier] = $product_list;
}
}
//.........这里部分代码省略.........
示例11: 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);
}
示例12: getPriceRangeForSearchBloc
public static function getPriceRangeForSearchBloc($search, $id_criterion_group, $id_currency, $id_country, $id_group, $count_product = false, $selected_criterion = array(), $selected_criteria_groups_type = array())
{
global $cookie;
if (!$id_country) {
$id_country = (int) (version_compare(_PS_VERSION_, '1.5.0.0', '>=') ? Context::getContext()->country->id : Country::getDefaultCountryId());
}
$search['display_empty_criteria'] = false;
$leftJoinWhereCriterion = self::makeLeftJoinWhereCriterion('getPriceRangeForSearchBloc', $search, $cookie->id_lang, $selected_criterion, $selected_criteria_groups_type, $id_criterion_group, false, $id_currency, $id_country, $id_group, true, true);
$now = date('Y-m-d H:i:s');
$minIdProduct = self::getMinIdProductSlider($search, $id_criterion_group, $id_currency, $id_country, $id_group, $count_product, $selected_criterion, $selected_criteria_groups_type);
list($taxConversion, $taxConversionForReduction, $specificPriceCondition, $specificPriceGroupCondition) = self::getPriceRangeConditions($id_group);
if ($leftJoinWhereCriterion['nbSelectedCriterions'] > 0 && ($leftJoinWhereCriterion['priceIncluded'] || $leftJoinWhereCriterion['productTableIncluded'])) {
$specificPriceCondition .= $specificPriceGroupCondition;
}
$return = array();
$query_min = 'SELECT app.price_wt as min_price, app.`reduction_amount`, app.`reduction_type`, app.`reduction_tax`, app.id_currency, acp.id_product, app.id_country, ' . self::_getScoreQuery(version_compare(_PS_VERSION_, '1.5.0.0', '>=') ? Context::getContext()->shop->id : 0, $id_currency, $id_country, $id_group, true, true) . '
FROM `' . _DB_PREFIX_ . 'pm_advancedsearch_product_price_' . (int) $search['id_search'] . '` app
LEFT JOIN `' . _DB_PREFIX_ . 'pm_advancedsearch_cache_product_' . (int) $search['id_search'] . '` acp ON (app.`id_cache_product` = acp.`id_cache_product`)' . (AdvancedSearchCoreClass::_isFilledArray($leftJoinWhereCriterion['join']) ? implode(' ', $leftJoinWhereCriterion['join']) : '') . ' WHERE acp.`id_product` = ' . (int) $minIdProduct . ' AND ' . ' ((app.`from` = \'0000-00-00 00:00:00\' OR \'' . $now . '\' >= app.`from`) AND (app.`to` = \'0000-00-00 00:00:00\' OR \'' . $now . '\' <= app.`to`)) AND ' . ' ((app.`valid_id_specific_price`=1 AND app.`is_specific`=1 AND app.`id_currency` IN (0, ' . (int) $id_currency . ')) OR app.`has_no_specific`=1) AND ' . (AdvancedSearchCoreClass::_isFilledArray($leftJoinWhereCriterion['where']) ? implode(' AND ', $leftJoinWhereCriterion['where']) : ' 1 ') . ' AND app.`id_country` IN (0, ' . (int) $id_country . ') ' . ' AND app.`id_group` IN (0, ' . (int) $id_group . ') ' . (version_compare(_PS_VERSION_, '1.5.0.0', '>=') ? ' AND app.`id_shop` IN (0, ' . implode(', ', Shop::getContextListShopID()) . ') ' : '') . ' ORDER BY score DESC, ' . $specificPriceCondition . ' ASC';
$row = Db::getInstance()->getRow($query_min);
if (version_compare(_PS_VERSION_, '1.5.0.0', '>=')) {
$tax_rate = Tax::getProductTaxRate((int) $row['id_product']);
} else {
$tax_rate = Tax::getProductTaxRateViaRules((int) $row['id_product'], (int) $id_country, 0, 0);
if ($tax_rate === false) {
$tax_rate = 0;
}
}
$reduction_amount = $row['reduction_amount'];
$reduction_type = $row['reduction_type'];
$reduction_tax = $row['reduction_tax'];
if (floor($row['min_price']) == 0) {
$reduction_amount = 0;
}
if (Product::$_taxCalculationMethod != PS_TAX_EXC) {
if ($reduction_type == 'amount') {
if (!$reduction_tax) {
$reduction_amount = $reduction_amount * (1 + $tax_rate / 100);
}
$price_ttc = $row['min_price'] * (1 + $tax_rate / 100) - $reduction_amount;
} else {
$price_ttc = ($row['min_price'] - $reduction_amount) * (1 + $tax_rate / 100);
}
$return[0]['min_price'] = floor($price_ttc);
} else {
if ($reduction_type == 'amount') {
if ($reduction_tax) {
$reduction_amount = $reduction_amount / (1 + $tax_rate / 100);
}
}
$return[0]['min_price'] = floor($row['min_price'] - $reduction_amount);
}
$return[0]['min_price_id_currency'] = $row['id_currency'];
$return[0]['min_price'] = self::getGroupReducedPrice((int) $row['id_product'], $id_group, $return[0]['min_price']);
$maxIdProduct = self::getMaxIdProductSlider($search, $id_criterion_group, $id_currency, $id_country, $id_group, $count_product, $selected_criterion, $selected_criteria_groups_type);
$query_max = 'SELECT app.price_wt as max_price, app.`reduction_amount`, app.`reduction_type`, app.`reduction_tax`, acp.id_product, app.id_currency, app.id_country, ' . self::_getScoreQuery(version_compare(_PS_VERSION_, '1.5.0.0', '>=') ? Context::getContext()->shop->id : 0, $id_currency, $id_country, $id_group, true, true) . '
FROM `' . _DB_PREFIX_ . 'pm_advancedsearch_product_price_' . (int) $search['id_search'] . '` app
LEFT JOIN `' . _DB_PREFIX_ . 'pm_advancedsearch_cache_product_' . (int) $search['id_search'] . '` acp ON (app.`id_cache_product` = acp.`id_cache_product`)' . (AdvancedSearchCoreClass::_isFilledArray($leftJoinWhereCriterion['join']) ? implode(' ', $leftJoinWhereCriterion['join']) : '') . ' WHERE acp.`id_product` = ' . (int) $maxIdProduct . ' AND ' . ' ((app.`from` = \'0000-00-00 00:00:00\' OR \'' . $now . '\' >= app.`from`) AND (app.`to` = \'0000-00-00 00:00:00\' OR \'' . $now . '\' <= app.`to`)) AND ' . ' ((app.`valid_id_specific_price`=1 AND app.`is_specific`=1 AND app.`id_currency` IN (0, ' . (int) $id_currency . ')) OR app.`has_no_specific`=1) AND ' . (AdvancedSearchCoreClass::_isFilledArray($leftJoinWhereCriterion['where']) ? implode(' AND ', $leftJoinWhereCriterion['where']) : ' 1 ') . ' AND app.`id_country` IN (0, ' . (int) $id_country . ') ' . ' AND app.`id_group` IN (0, ' . (int) $id_group . ') ' . (version_compare(_PS_VERSION_, '1.5.0.0', '>=') ? ' AND app.`id_shop` IN (0, ' . implode(', ', Shop::getContextListShopID()) . ') ' : '') . ' ORDER BY score DESC, ' . $specificPriceCondition . ' DESC';
$row = Db::getInstance()->getRow($query_max);
if (version_compare(_PS_VERSION_, '1.5.0.0', '>=')) {
$tax_rate = Tax::getProductTaxRate((int) $row['id_product']);
} else {
$tax_rate = Tax::getProductTaxRateViaRules((int) $row['id_product'], (int) $id_country, 0, 0);
if ($tax_rate === false) {
$tax_rate = 0;
}
}
$reduction_amount = $row['reduction_amount'];
$reduction_type = $row['reduction_type'];
$reduction_tax = $row['reduction_tax'];
if (Product::$_taxCalculationMethod != PS_TAX_EXC) {
if ($reduction_type == 'amount') {
if (!$reduction_tax) {
$reduction_amount = $reduction_amount * (1 + $tax_rate / 100);
}
$price_ttc = $row['max_price'] * (1 + $tax_rate / 100) - $reduction_amount;
} else {
$price_ttc = ($row['max_price'] - $reduction_amount) * (1 + $tax_rate / 100);
}
$return[0]['max_price'] = ceil($price_ttc);
} else {
if ($reduction_type == 'amount') {
if ($reduction_tax) {
$reduction_amount = $reduction_amount / (1 + $tax_rate / 100);
}
}
$return[0]['max_price'] = ceil($row['max_price'] - $reduction_amount);
}
$return[0]['max_price_id_currency'] = $row['id_currency'];
$return[0]['max_price'] = self::getGroupReducedPrice((int) $row['id_product'], $id_group, $return[0]['max_price']);
return $return;
}
示例13: Customer
} else {
Tools::redirectLink(__PS_BASE_URI__ . 'order.php?step=1');
}
$customer = new Customer((int) $cart->id_customer);
if (!Validate::isLoadedObject($customer)) {
Tools::redirectLink(__PS_BASE_URI__ . 'order.php?step=1');
}
/* Assign cart summary info */
$summary = $cart->getSummaryDetails();
$customizedDatas = Product::getAllCustomizedDatas((int) $cart->id);
// override customization tax rate with real tax (tax rules)
foreach ($summary['products'] as &$productUpdate) {
$productId = (int) (isset($productUpdate['id_product']) ? $productUpdate['id_product'] : $productUpdate['product_id']);
$productAttributeId = (int) (isset($productUpdate['id_product_attribute']) ? $productUpdate['id_product_attribute'] : $productUpdate['product_attribute_id']);
if (isset($customizedDatas[$productId][$productAttributeId])) {
$productUpdate['tax_rate'] = Tax::getProductTaxRate($productId, $cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
}
}
Product::addCustomizationPrice($summary['products'], $customizedDatas);
if ($free_ship = Tools::convertPrice((double) Configuration::get('PS_SHIPPING_FREE_PRICE'), new Currency((int) $cart->id_currency))) {
$discounts = $cart->getDiscounts();
$total_free_ship = $free_ship - ($summary['total_products_wt'] + $summary['total_discounts']);
foreach ($discounts as $discount) {
if ($discount['id_discount_type'] == 3 || $discount['id_discount_type'] == 4 || $discount['id_discount_type'] == 5) {
$total_free_ship = 0;
break;
}
}
$smarty->assign('free_ship', $total_free_ship);
}
// for compatibility with 1.2 themes
示例14: displayAttributes
public function displayAttributes()
{
global $currentIndex, $cookie;
if (isset($this->_list['obj'])) {
$nbAttributes = sizeof($this->_list['obj']);
echo '<h3>' . $this->_list['message'] . ' ' . $nbAttributes . ' ' . $this->l('found') . '</h3>';
if (!$nbAttributes) {
return;
}
$this->fieldsDisplay = array('ID' => array('title' => $this->l('ID')), 'manufacturer' => array('title' => $this->l('Manufacturer')), 'reference' => array('title' => $this->l('Reference')), 'name' => array('title' => $this->l('Name')), 'price' => array('title' => $this->l('Price')), 'tax' => array('title' => $this->l('Tax')), 'stock' => array('title' => $this->l('Stock')), 'weight' => array('title' => $this->l('Weight')), 'status' => array('title' => $this->l('Status')), 'action' => array('title' => $this->l('Actions')));
$currency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT'));
echo '
<table class="table" cellpadding="0" cellspacing="0">
<tr>';
foreach ($this->fieldsDisplay as $field) {
echo '<th' . (isset($field['width']) ? 'style="width: ' . $field['width'] . '"' : '') . '>' . $field['title'] . '</th>';
}
echo '
</tr>';
$attributes = array();
$prevAttributeId = '';
foreach ($this->_list['obj'] as $prod) {
if ($prevAttributeId == $prod['id_product_attribute']) {
$prod['combination_name'] = $attributes[$prod['id_product_attribute']]['combination_name'] . ', ' . $prod['group_name'] . ' : ' . $prod['attribute_name'];
} else {
$prod['combination_name'] = $prod['group_name'] . ' : ' . $prod['attribute_name'];
}
$attributes[$prod['id_product_attribute']] = $prod;
$prevAttributeId = $prod['id_product_attribute'];
}
foreach ($attributes as $prod) {
$taxrate = Tax::getProductTaxRate($prod['id_product']);
echo '
<tr>
<td>' . $prod['id_product'] . '</td>
<td align="center">' . ($prod['manufacturer_name'] != NULL ? stripslashes($prod['manufacturer_name']) : '--') . '</td>
<td>' . $prod['reference'] . '</td>
<td><a href="index.php?tab=AdminCatalog&id_product=' . $prod['id_product'] . '&addproduct&token=' . Tools::getAdminToken('AdminCatalog' . (int) Tab::getIdFromClassName('AdminCatalog') . (int) $cookie->id_employee) . '">' . stripslashes($prod['name']) . ' (' . $prod['combination_name'] . ')' . '</a></td>
<td>' . Tools::displayPrice(Product::getPriceStatic((int) $prod['id_product'], true, $prod['id_product_attribute']), $currency) . '</td>
<td>' . (double) $taxrate . '% </td>
<td align="center">' . $prod['quantity'] . '</td>
<td align="center">' . ($prod['weight'] + $prod['product_weight']) . ' ' . Configuration::get('PS_WEIGHT_UNIT') . '</td>
<td align="center"><a href="index.php?tab=AdminCatalog&id_product=' . $prod['id_product'] . '&status&token=' . Tools::getAdminToken('AdminCatalog' . (int) Tab::getIdFromClassName('AdminCatalog') . (int) $cookie->id_employee) . '"><img src="../img/admin/' . ($prod['active'] ? 'enabled.gif' : 'disabled.gif') . '" alt="" /></a></td>
<td>
<a href="index.php?tab=AdminCatalog&id_product=' . $prod['id_product'] . '&addproduct&token=' . Tools::getAdminToken('AdminCatalog' . (int) Tab::getIdFromClassName('AdminCatalog') . (int) $cookie->id_employee) . '">
<img src="../img/admin/edit.gif" alt="' . $this->l('Modify this product') . '" /></a>
<a href="index.php?tab=AdminCatalog&id_product=' . $prod['id_product'] . '&deleteproduct&token=' . Tools::getAdminToken('AdminCatalog' . (int) Tab::getIdFromClassName('AdminCatalog') . (int) $cookie->id_employee) . '" onclick="return confirm(\'' . addslashes($this->l('Do you want to delete') . ' ' . $prod['name']) . ' ?\');">
<img src="../img/admin/delete.gif" alt="' . $this->l('Delete this product') . '" /></a>
</td>
</tr>';
}
echo '</table><br /><br />';
}
}
示例15: getContent
/**
* @see HTMLTemplate::getContent()
*/
public function getContent()
{
$final_pdf = '';
require_once _PS_MODULE_DIR_ . 'erpillicopresta/models/ErpSupplyOrderCustomer.php';
require_once _PS_MODULE_DIR_ . 'erpillicopresta/models/ErpSupplier.php';
require_once _PS_MODULE_DIR_ . 'erpillicopresta/models/ErpSupplyOrder.php';
// Retrieval of the link between supplier order AND customer order if exists
$erp_supply_order_customer = ErpSupplyOrderCustomer::getSupplyOrdersCustomer((int) $this->supply_order->id);
$supply_order_details = $this->supply_order->getEntriesCollection((int) $this->supply_order->id_lang);
$this->roundSupplyOrderDetails($supply_order_details);
$supply_order_receipt_history = array();
foreach ($supply_order_details as $supply_order_detail) {
$supply_order_receipt_history[$supply_order_detail->id] = $this->getSupplyOrderReceiptHistoryCollection($supply_order_detail->id);
}
$this->roundSupplyOrder($this->supply_order);
$tax_order_summary = $this->getTaxOrderSummary();
$currency = new Currency((int) $this->supply_order->id_currency);
//-ERP information
// get additional supplier information
$erp_supplier = null;
$erp_supplier_fax = '';
if (isset($this->supply_order->id_supplier) && (int) $this->supply_order->id_supplier > 0) {
$id_erpip_supplier = ErpSupplier::getErpSupplierIdBySupplierId((int) $this->supply_order->id_supplier);
if ((int) $id_erpip_supplier > 0) {
$erp_supplier = new ErpSupplier((int) $id_erpip_supplier);
}
}
if ($erp_supplier != null) {
$erp_supplier_fax = $erp_supplier->fax;
}
//-ERP information
// get additional supply order information
$erp_supply_order = null;
if (isset($this->supply_order->id) && (int) $this->supply_order->id > 0) {
$id_erpip_supply_order = ErpSupplyOrder::getErpSupplierOrderIdBySupplierOrderId((int) $this->supply_order->id);
if ((int) $id_erpip_supply_order > 0) {
$erp_supply_order = new ErpSupplyOrder((int) $id_erpip_supply_order);
}
}
// get shipping address
$adresse_livraison = self::getStoreByName('Adresse livraison');
$this->smarty->assign(array('warehouse' => $this->warehouse, 'address_warehouse' => $this->address_warehouse, 'address_supplier' => $this->address_supplier, 'supply_order' => $this->supply_order, 'erp_supply_order' => $erp_supply_order, 'supply_order_details' => $supply_order_details, 'supply_order_receipt_history' => $supply_order_receipt_history, 'tax_order_summary' => $tax_order_summary, 'currency' => $currency, 'fax' => $erp_supplier_fax, 'action' => Tools::getValue('submitAction'), 'shop_name' => Configuration::get('PS_SHOP_NAME'), 'shop_addr' => Configuration::get('PS_SHOP_ADDR1'), 'shop_addr2' => Configuration::get('PS_SHOP_ADDR2'), 'shop_code' => Configuration::get('PS_SHOP_CODE'), 'shop_city' => Configuration::get('PS_SHOP_CITY'), 'shop_country' => Configuration::get('PS_SHOP_COUNTRY'), 'adresse_livraison' => $adresse_livraison));
// if there is an supply order generated : display a PDF page by customer
if (!empty($erp_supply_order_customer)) {
// distribution by customer : one page per customer
$final_item = array();
foreach ($erp_supply_order_customer as $item) {
$final_item[$item['id_customer']][] = $item;
}
$pdf_customer = '';
// Create page per customer
foreach ($final_item as $id_customer => $datas) {
$customer = new Customer((int) $id_customer);
$order_detail = array();
foreach ($datas as $data) {
$order_detail_line = new OrderDetailCore((int) $data['id_order_detail']);
$order_detail_line->tax_rate = Tax::getProductTaxRate($order_detail_line->product_id);
$order_detail[] = $order_detail_line;
}
$this->smarty->assign(array('is_customer_page' => 'true'));
$this->smarty->assign(array('supply_order_details' => $order_detail));
$this->smarty->assign(array('customer_name' => $customer->lastname . ' ' . $customer->firstname));
$pdf_customer .= '<div style="page-break-before:always"><div>';
$pdf_customer .= $this->smarty->fetch(_PS_MODULE_DIR_ . 'erpillicopresta/views/templates/admin/pdf/erp-supply-order-customer.tpl');
}
$this->smarty->assign(array('is_customer_page' => 'false'));
$this->smarty->assign(array('supply_order_details' => $supply_order_details));
$final_pdf = $this->smarty->fetch(_PS_MODULE_DIR_ . 'erpillicopresta/views/templates/admin/pdf/erp-supply-order.tpl') . $pdf_customer;
} else {
$final_pdf = $this->smarty->fetch(_PS_MODULE_DIR_ . 'erpillicopresta/views/templates/admin/pdf/erp-supply-order.tpl');
}
return $final_pdf;
}