本文整理汇总了PHP中Product::getPriceStatic方法的典型用法代码示例。如果您正苦于以下问题:PHP Product::getPriceStatic方法的具体用法?PHP Product::getPriceStatic怎么用?PHP Product::getPriceStatic使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Product
的用法示例。
在下文中一共展示了Product::getPriceStatic方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getList
public function getList($id_lang, $orderBy = NULL, $orderWay = NULL, $start = 0, $limit = NULL)
{
$orderByPriceFinal = empty($orderBy) ? Tools::getValue($this->table . 'Orderby', 'id_' . $this->table) : $orderBy;
$orderWayPriceFinal = empty($orderWay) ? Tools::getValue($this->table . 'Orderway', 'ASC') : $orderWay;
if ($orderByPriceFinal == 'price_final') {
$orderBy = 'id_' . $this->table;
$orderWay = 'ASC';
}
parent::getList($id_lang, $orderBy, $orderWay, $start, $limit);
/* update product quantity with attributes ...*/
if ($this->_list) {
$nb = count($this->_list);
for ($i = 0; $i < $nb; $i++) {
Attribute::updateQtyProduct($this->_list[$i]);
}
/* update product final price */
for ($i = 0; $i < $nb; $i++) {
$this->_list[$i]['price_tmp'] = Product::getPriceStatic($this->_list[$i]['id_product'], $usetax = true, $id_product_attribute = NULL, $decimals = 6, $divisor = NULL, $only_reduc = false, $usereduc = true, $quantity = 1, $forceAssociatedTax = true);
}
}
if ($orderByPriceFinal == 'price_final') {
if (strtolower($orderWayPriceFinal) == 'desc') {
uasort($this->_list, 'cmpPriceDesc');
} else {
uasort($this->_list, 'cmpPriceAsc');
}
}
for ($i = 0; $this->_list and $i < $nb; $i++) {
$this->_list[$i]['price_final'] = $this->_list[$i]['price_tmp'];
unset($this->_list[$i]['price_tmp']);
}
}
示例2: getList
public function getList($id_lang, $orderBy = NULL, $orderWay = NULL, $start = 0, $limit = NULL)
{
global $cookie;
$orderByPriceFinal = empty($orderBy) ? $cookie->__get($this->table . 'Orderby') ? $cookie->__get($this->table . 'Orderby') : 'id_' . $this->table : $orderBy;
$orderWayPriceFinal = empty($orderWay) ? $cookie->__get($this->table . 'Orderway') ? $cookie->__get($this->table . 'Orderby') : 'ASC' : $orderWay;
if ($orderByPriceFinal == 'price_final') {
$orderBy = 'id_' . $this->table;
$orderWay = 'ASC';
}
parent::getList($id_lang, $orderBy, $orderWay, $start, $limit);
/* update product quantity with attributes ...*/
if ($this->_list) {
$nb = count($this->_list);
for ($i = 0; $i < $nb; $i++) {
Attribute::updateQtyProduct($this->_list[$i]);
}
/* update product final price */
for ($i = 0; $i < $nb; $i++) {
$this->_list[$i]['price_tmp'] = Product::getPriceStatic($this->_list[$i]['id_product'], true, NULL, 6, NULL, false, true, 1, true);
}
}
if ($orderByPriceFinal == 'price_final') {
if (strtolower($orderWayPriceFinal) == 'desc') {
uasort($this->_list, 'cmpPriceDesc');
} else {
uasort($this->_list, 'cmpPriceAsc');
}
}
for ($i = 0; $this->_list and $i < $nb; $i++) {
$this->_list[$i]['price_final'] = $this->_list[$i]['price_tmp'];
unset($this->_list[$i]['price_tmp']);
}
}
示例3: setProduct
public function setProduct($product, $combination)
{
// create the product
$context = Context::getContext();
$this->give_it_product = new GiveItSdkProduct();
$this->give_it_product->setCurrency($context->currency->iso_code);
$usetax = Product::getTaxCalculationMethod((int) $context->customer->id) != PS_TAX_EXC;
if ($combination['id_product_attribute'] == 0) {
$combination['attributes'] = '';
$image = Product::getCover($product->id);
} else {
$comb = new Combination($combination['id_product_attribute']);
if ($image = $comb->getWsImages()) {
$image = $image[0];
$image['id_image'] = $image['id'];
}
}
$image['id_product'] = $product->id;
$image['id_image'] = Product::defineProductImage($image, Context::getContext()->language->id);
$img_profile = version_compare(_PS_VERSION_, '1.5', '<') ? 'home' : ImageType::getFormatedName('medium');
$image = $image ? $context->link->getImageLink($product->link_rewrite, $image['id_image'], $img_profile) : '';
// first, set the product details.
$this->give_it_product->setProductDetails(array('code' => $product->id . '_' . $combination['id_product_attribute'], 'price' => (int) (Product::getPriceStatic((int) $product->id, $usetax, $combination['id_product_attribute']) * 100), 'name' => $product->name . ($combination['attributes'] ? ' : ' . $combination['attributes'] : ''), 'image' => $image));
$delivery = $this->setDelivery();
// add the delivery option to the product
$this->give_it_product->addBuyerOption($delivery);
//We should validate this product
$this->product_valid = $this->give_it_product->validate();
}
示例4: _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)));
}
示例5: pwa_order
public function pwa_order($data)
{
$prefix = _DB_PREFIX_;
$pwa_order_status = $data['amznPmtsPaymentStatus'];
$pwa_order_id = $data['amznPmtsOrderIds'];
if (isset($data['refresh']) && $data['refresh'] != '') {
$refresh = $data['refresh'];
} else {
$refresh = 'yes';
}
if (isset($data['CartId']) && $data['CartId'] > 0) {
$CartId = $data['CartId'];
} else {
$CartId = 0;
}
$tablename = $prefix . 'pwa_orders';
$sql = 'SELECT * from `' . $tablename . '` where `amazon_order_id` = "' . $pwa_order_id . '" ';
$result = Db::getInstance()->ExecuteS($sql);
if (empty($result)) {
$tablename = $prefix . 'orders';
$date = date('Y-m-d H:i:s');
$sql = 'INSERT into `' . $tablename . '` (`current_state` , `id_cart` , `payment` , `module` , `date_add` ) VALUES( 99, "' . $CartId . '", "Pay with Amazon", "pwapresta", "' . $date . '" )';
Db::getInstance()->Execute($sql);
$order_id = Db::getInstance()->Insert_ID();
$tablename = $prefix . 'pwa_orders';
$sql = 'INSERT into `' . $tablename . '` (`prestashop_order_id` , `amazon_order_id` ) VALUES( "' . $order_id . '", "' . $pwa_order_id . '" )';
Db::getInstance()->Execute($sql);
} else {
$order_id = $result[0]['prestashop_order_id'];
}
$products = $this->context->cart->getProducts();
foreach ($products as $product) {
if (Configuration::get('PS_TAX_ADDRESS_TYPE') == 'id_address_invoice') {
$address_id = (int) $this->id_address_invoice;
} else {
$address_id = (int) $product['id_address_delivery'];
}
// Get delivery address of the product from the cart
if (!Address::addressExists($address_id)) {
$address_id = null;
}
$virtual_context = Context::getContext()->cloneContext();
$virtual_context->cart = $this->context->cart;
$product_price = Product::getPriceStatic((int) $product['id_product'], false, (int) $product['id_product_attribute'], 2, null, false, true, $product['quantity'], false, (int) $this->context->cart->id_customer ? (int) $this->context->cart->id_customer : null, (int) $this->context->cart->id, (int) $address_id ? (int) $address_id : null, $null, true, true, $virtual_context);
$tablename = $prefix . 'pwa_order_products';
$sql = 'INSERT into `' . $tablename . '` (`id_cart` , `id_product` , `id_product_attribute` , `quantity` , `amount` , `amount_excl` , `sku` , `title` ) VALUES( "' . $this->context->cart->id . '", "' . $product["id_product"] . '", "' . $product["id_product_attribute"] . '", "' . $product["quantity"] . '", "' . $product["price_wt"] . '", "' . $product_price . '", "' . $product["reference"] . '", "' . $product["name"] . '" )';
Db::getInstance()->Execute($sql);
//$this->context->cart->deleteProduct($product["id_product"]);
}
$this->context->smarty->assign(array('order_id' => $order_id, 'pwa_order_id' => $pwa_order_id, 'pwa_order_status' => $pwa_order_status, 'refresh' => $refresh));
$this->setTemplate('pwa_order.tpl');
}
示例6: hookNewOrder
public function hookNewOrder($params)
{
if (!$this->_merchant_order or empty($this->_merchant_mails)) {
return;
}
// Getting differents vars
$id_lang = intval(Configuration::get('PS_LANG_DEFAULT'));
$currency = $params['currency'];
$configuration = Configuration::getMultiple(array('PS_SHOP_EMAIL', 'PS_MAIL_METHOD', 'PS_MAIL_SERVER', 'PS_MAIL_USER', 'PS_MAIL_PASSWD', 'PS_SHOP_NAME'));
$order = $params['order'];
$customer = $params['customer'];
$delivery = new Address(intval($order->id_address_delivery));
$invoice = new Address(intval($order->id_address_invoice));
$order_date_text = Tools::displayDate($order->date_add, intval($id_lang));
$carrier = new Carrier(intval($order->id_carrier));
$message = $order->getFirstMessage();
if (!$message or empty($message)) {
$message = $this->l('No message');
}
$itemsTable = '';
foreach ($params['cart']->getProducts() as $key => $product) {
$unit_price = Product::getPriceStatic($product['id_product'], true, $product['id_product_attribute']);
$price = Product::getPriceStatic($product['id_product'], true, $product['id_product_attribute'], 6, NULL, false, true, $product['quantity']);
$itemsTable .= '<tr style="background-color:' . ($key % 2 ? '#DDE2E6' : '#EBECEE') . ';">
<td style="padding:0.6em 0.4em;">' . $product['reference'] . '</td>
<td style="padding:0.6em 0.4em;"><strong>' . $product['name'] . (isset($product['attributes_small']) ? ' ' . $product['attributes_small'] : '') . '</strong></td>
<td style="padding:0.6em 0.4em; text-align:right;">' . Tools::displayPrice($unit_price, $currency, false, false) . '</td>
<td style="padding:0.6em 0.4em; text-align:center;">' . intval($product['quantity']) . '</td>
<td style="padding:0.6em 0.4em; text-align:right;">' . Tools::displayPrice($price * $product['quantity'], $currency, false, false) . '</td>
</tr>';
}
foreach ($params['cart']->getDiscounts() as $discount) {
$itemsTable .= '<tr style="background-color:#EBECEE;">
<td colspan="4" style="padding:0.6em 0.4em; text-align:right;">' . $this->l('Voucher code:') . ' ' . $discount['name'] . '</td>
<td style="padding:0.6em 0.4em; text-align:right;">-' . Tools::displayPrice($discount['value_real'], $currency, false, false) . '</td>
</tr>';
}
if ($delivery->id_state) {
$delivery_state = new State(intval($delivery->id_state));
}
if ($invoice->id_state) {
$invoice_state = new State(intval($invoice->id_state));
}
// Filling-in vars for email
$template = 'new_order';
$subject = $this->l('New order');
$templateVars = array('{firstname}' => $customer->firstname, '{lastname}' => $customer->lastname, '{email}' => $customer->email, '{delivery_company}' => $delivery->company, '{delivery_firstname}' => $delivery->firstname, '{delivery_lastname}' => $delivery->lastname, '{delivery_address1}' => $delivery->address1, '{delivery_address2}' => $delivery->address2, '{delivery_city}' => $delivery->city, '{delivery_postal_code}' => $delivery->postcode, '{delivery_country}' => $delivery->country, '{delivery_state}' => $delivery->id_state ? $delivery_state->name : '', '{delivery_phone}' => $delivery->phone, '{delivery_other}' => $delivery->other, '{invoice_company}' => $invoice->company, '{invoice_firstname}' => $invoice->firstname, '{invoice_lastname}' => $invoice->lastname, '{invoice_address2}' => $invoice->address2, '{invoice_address1}' => $invoice->address1, '{invoice_city}' => $invoice->city, '{invoice_postal_code}' => $invoice->postcode, '{invoice_country}' => $invoice->country, '{invoice_state}' => $invoice->id_state ? $invoice_state->name : '', '{invoice_phone}' => $invoice->phone, '{invoice_other}' => $invoice->other, '{order_name}' => sprintf("%06d", $order->id), '{shop_name}' => Configuration::get('PS_SHOP_NAME'), '{date}' => $order_date_text, '{carrier}' => $carrier->name == '0' ? Configuration::get('PS_SHOP_NAME') : $carrier->name, '{payment}' => $order->payment, '{items}' => $itemsTable, '{total_paid}' => Tools::displayPrice($order->total_paid, $currency), '{total_products}' => Tools::displayPrice($order->getTotalProductsWithTaxes(), $currency), '{total_discounts}' => Tools::displayPrice($order->total_discounts, $currency), '{total_shipping}' => Tools::displayPrice($order->total_shipping, $currency), '{total_wrapping}' => Tools::displayPrice($order->total_wrapping, $currency), '{currency}' => $currency->sign, '{message}' => $message);
$iso = Language::getIsoById(intval($id_lang));
if (file_exists(dirname(__FILE__) . '/mails/' . $iso . '/' . $template . '.txt') and file_exists(dirname(__FILE__) . '/mails/' . $iso . '/' . $template . '.html')) {
Mail::Send($id_lang, $template, $subject, $templateVars, explode(self::__MA_MAIL_DELIMITOR__, $this->_merchant_mails), NULL, $configuration['PS_SHOP_EMAIL'], $configuration['PS_SHOP_NAME'], NULL, NULL, dirname(__FILE__) . '/mails/');
}
}
示例7: sendCampaign
public function sendCampaign()
{
// get abandoned cart :
$sql = "SELECT * FROM (\n\t\tSELECT\n\t\tCONCAT(LEFT(c.`firstname`, 1), '. ', c.`lastname`) `customer`, a.id_cart total, ca.name carrier, c.id_customer, a.id_cart, a.date_upd,a.date_add,\n\t\t\t\tIF (IFNULL(o.id_order, 'Non ordered') = 'Non ordered', IF(TIME_TO_SEC(TIMEDIFF('" . date('Y-m-d H:i:s') . "', a.`date_add`)) > 86400, 'Abandoned cart', 'Non ordered'), o.id_order) id_order, IF(o.id_order, 1, 0) badge_success, IF(o.id_order, 0, 1) badge_danger, IF(co.id_guest, 1, 0) id_guest\n\t\tFROM `" . _DB_PREFIX_ . "cart` a \n\t\t\t\tJOIN `" . _DB_PREFIX_ . "customer` c ON (c.id_customer = a.id_customer)\n\t\t\t\tLEFT JOIN `" . _DB_PREFIX_ . "currency` cu ON (cu.id_currency = a.id_currency)\n\t\t\t\tLEFT JOIN `" . _DB_PREFIX_ . "carrier` ca ON (ca.id_carrier = a.id_carrier)\n\t\t\t\tLEFT JOIN `" . _DB_PREFIX_ . "orders` o ON (o.id_cart = a.id_cart)\n\t\t\t\tLEFT JOIN `" . _DB_PREFIX_ . "connections` co ON (a.id_guest = co.id_guest AND TIME_TO_SEC(TIMEDIFF('" . date('Y-m-d H:i:s') . "', co.`date_add`)) < 1800)\n\t\t) AS toto WHERE id_order='Abandoned cart'";
$currency = Context::getContext()->currency->sign;
$defaultLanguage = new Language((int) Configuration::get('PS_LANG_DEFAULT'));
$abandoned_carts = Db::getInstance()->ExecuteS($sql);
// get all available campaigns
$sqlCampaigns = 'SELECT * FROM `' . _DB_PREFIX_ . 'campaign` WHERE active=1';
$allCampaigns = Db::getInstance()->ExecuteS($sqlCampaigns);
// loop on all abandoned carts
foreach ($abandoned_carts as $abncart) {
// loop on all available campaigns
foreach ($allCampaigns as $camp) {
$cartIsOnCampaign = $this->checkIfCartIsOnCampaign($abncart['date_add'], $camp['execution_time_day'], $camp['execution_time_hour']);
if ($cartIsOnCampaign) {
$id_lang = (int) Configuration::get('PS_LANG_DEFAULT');
$customer = new Customer($abncart['id_customer']);
$cR = new CartRule($camp['id_voucher'], $id_lang);
$cart = new Cart($abncart['id_cart']);
$products = $cart->getProducts();
$campM = new Campaign($camp['id_campaign']);
if (!empty($products)) {
$cart_content = $campM->getCartContentHeader();
} else {
$cart_content = '';
}
foreach ($products as $prod) {
$p = new Product($prod['id_product'], true, $id_lang);
$price_no_tax = Product::getPriceStatic($p->id, false, null, 2, null, false, true, 1, false, null, $abncart['id_cart'], null, $null, true, true, null, false, false);
$total_no_tax = $prod['cart_quantity'] * $price_no_tax;
$images = Image::getImages((int) $id_lang, (int) $p->id);
$link = new Link();
$cart_content .= '<tr >
<td align="center" ><img src="' . $link->getImageLink($p->link_rewrite, $images[0]['id_image']) . '" width="80"/></td>
<td align="center" ><a href="' . $link->getProductLink($p) . '"/>' . $p->name . '</a></td>
<td align="center" >' . Tools::displayprice($price_no_tax) . '</td>
<td align="center" >' . $prod['cart_quantity'] . '</td>
<td align="center" >' . Tools::displayprice($total_no_tax) . '</td>
</tr>';
}
$tpl_vars = array('{firstname}' => $customer->firstname, '{lastname}' => $customer->lastname, '{coupon_name}' => $cR->name, '{coupon_code}' => $cR->code, '{cart_content}' => $cart_content, '{coupon_value}' => $camp['voucher_amount_type'] == 'percent' ? $cR->reduction_percent . '%' : $currency . $cR->reduction_amount, '{coupon_valid_to}' => date('d/m/Y', strtotime($cR->date_to)), '{campaign_name}' => $camp['name']);
$path = _PS_ROOT_DIR_ . '/modules/superabandonedcart/mails/';
// send email to customer :
Mail::Send($id_lang, $campM->getFileName(), $camp['name'], $tpl_vars, $customer->email, null, null, null, null, null, $path, false, Context::getContext()->shop->id);
// Email to admin :
Mail::Send($id_lang, $campM->getFileName(), Mail::l(sprintf('Email sent to %s %s for campaign %s', $customer->lastname, $customer->firstname, $camp['name'])), $tpl_vars, Configuration::get('PS_SHOP_EMAIL'), null, null, null, null, null, $path, false, Context::getContext()->shop->id);
// echo 'ID ' . $abncart['id_cart'];
}
}
}
}
示例8: hookRightColumn
function hookRightColumn($params)
{
global $smarty;
$currency = new Currency(intval($params['cookie']->id_currency));
$bestsellers = ProductSale::getBestSalesLight(intval($params['cookie']->id_lang), 0, 5);
$best_sellers = array();
foreach ($bestsellers as $bestseller) {
$bestseller['price'] = Tools::displayPrice(Product::getPriceStatic(intval($bestseller['id_product'])), $currency);
$best_sellers[] = $bestseller;
}
$smarty->assign(array('best_sellers' => $best_sellers, 'mediumSize' => Image::getSize('medium')));
return $this->display(__FILE__, 'blockbestsellers.tpl');
}
示例9: getBestSellers
protected function getBestSellers($params)
{
if (Configuration::get('PS_CATALOG_MODE')) {
return false;
}
if (!($result = ProductSale::getBestSalesLight((int) $params['cookie']->id_lang, 0, 3))) {
return Configuration::get('PS_BLOCK_BESTSELLERS_DISPLAY') ? array() : false;
}
$currency = new Currency($params['cookie']->id_currency);
$usetax = Product::getTaxCalculationMethod((int) $this->context->customer->id) != PS_TAX_EXC;
foreach ($result as &$row) {
$row['price'] = Tools::displayPrice(Product::getPriceStatic((int) $row['id_product'], $usetax), $currency);
}
return $result;
}
示例10: assignPriceAndTax
/**
* Assign price and tax to the template
*/
protected function assignPriceAndTax()
{
die('coucou');
$id_customer = isset($this->context->customer) ? (int) $this->context->customer->id : 0;
$id_group = (int) Group::getCurrent()->id;
$id_country = $id_customer ? (int) Customer::getCurrentCountry($id_customer) : (int) Tools::getCountry();
$group_reduction = GroupReduction::getValueForProduct($this->product->id, $id_group);
if ($group_reduction === false) {
$group_reduction = Group::getReduction((int) $this->context->cookie->id_customer) / 100;
}
// Tax
$tax = (double) $this->product->getTaxesRate(new Address((int) $this->context->cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')}));
$this->context->smarty->assign('tax_rate', $tax);
$product_price_with_tax = Product::getPriceStatic($this->product->id, true, null, 6) * 10;
if (Product::$_taxCalculationMethod == PS_TAX_INC) {
$product_price_with_tax = Tools::ps_round($product_price_with_tax, 2);
}
$product_price_without_eco_tax = (double) $product_price_with_tax - $this->product->ecotax;
$ecotax_rate = (double) Tax::getProductEcotaxRate($this->context->cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
$ecotax_tax_amount = Tools::ps_round($this->product->ecotax, 2);
if (Product::$_taxCalculationMethod == PS_TAX_INC && (int) Configuration::get('PS_TAX')) {
$ecotax_tax_amount = Tools::ps_round($ecotax_tax_amount * (1 + $ecotax_rate / 100), 2);
}
$id_currency = (int) $this->context->cookie->id_currency;
$id_product = (int) $this->product->id;
$id_shop = $this->context->shop->id;
$quantity_discounts = SpecificPrice::getQuantityDiscounts($id_product, $id_shop, $id_currency, $id_country, $id_group, null, true, (int) $this->context->customer->id);
foreach ($quantity_discounts as &$quantity_discount) {
if ($quantity_discount['id_product_attribute']) {
$combination = new Combination((int) $quantity_discount['id_product_attribute']);
$attributes = $combination->getAttributesName((int) $this->context->language->id);
foreach ($attributes as $attribute) {
$quantity_discount['attributes'] = $attribute['name'] . ' - ';
}
$quantity_discount['attributes'] = rtrim($quantity_discount['attributes'], ' - ');
}
if ((int) $quantity_discount['id_currency'] == 0 && $quantity_discount['reduction_type'] == 'amount') {
$quantity_discount['reduction'] = Tools::convertPriceFull($quantity_discount['reduction'], null, Context::getContext()->currency);
}
}
$product_price = $this->product->getPrice(Product::$_taxCalculationMethod == PS_TAX_INC, false) * 10;
$address = new Address($this->context->cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
$this->context->smarty->assign(array('quantity_discounts' => $this->formatQuantityDiscounts($quantity_discounts, $product_price, (double) $tax, $ecotax_tax_amount), 'ecotax_tax_inc' => $ecotax_tax_amount, 'ecotax_tax_exc' => Tools::ps_round($this->product->ecotax, 2), 'ecotaxTax_rate' => $ecotax_rate, 'productPriceWithoutEcoTax' => (double) $product_price_without_eco_tax, 'group_reduction' => $group_reduction, 'no_tax' => Tax::excludeTaxeOption() || !$this->product->getTaxesRate($address), 'ecotax' => !count($this->errors) && $this->product->ecotax > 0 ? Tools::convertPrice((double) $this->product->ecotax) : 0, 'tax_enabled' => Configuration::get('PS_TAX') && !Configuration::get('AEUC_LABEL_TAX_INC_EXC'), 'customer_group_without_tax' => Group::getPriceDisplayMethod($this->context->customer->id_default_group)));
}
示例11: getSummary
/**
* Get datas for return of request
* @return array Datas
*/
public function getSummary()
{
$this->getCurrency();
list($id_cart, $id_order, $message) = $this->validateOrder();
if (!$id_cart) {
return false;
}
$det = $this->cart->getSummaryDetails();
$detail = array();
$total_discount = 0;
foreach ($det['products'] as $key => &$product) {
$product['price_without_quantity_discount'] = Product::getPriceStatic($product['id_product'], false, $product['id_product_attribute'], 6, null, false, false);
// product price without tax
$discount = $product['price_without_quantity_discount'] - $product["price"];
$total_discount += $discount * $product["quantity"];
$detail[] = array('code' => $product["id_product"], 'unitPrice' => array('amount' => $this->formatNumber($product["price_without_quantity_discount"], 2), 'currency' => $this->currency->iso_code), 'unitDiscount' => array('amount' => $this->formatNumber($discount, 2), 'currency' => $this->currency->iso_code), 'unitTax' => array('amount' => $this->formatNumber($product["price_wt"] - $product["price"], 2), 'currency' => $this->currency->iso_code), 'quantity' => $product["quantity"], 'total' => array('amount' => $this->formatNumber($product["total_wt"], 2), 'currency' => $this->currency->iso_code));
}
$shipping_tax = $det["total_shipping"] - $det["total_shipping_tax_exc"];
$response = array('orderCostSummary' => array('subTotal' => array('amount' => $this->formatNumber($det["total_products"], 2), 'currency' => $this->currency->iso_code), 'discount' => array('amount' => $this->formatNumber($total_discount + $det["total_discounts"], 2), 'currency' => $this->currency->iso_code), 'shippingCost' => array('amount' => $this->formatNumber($det["total_shipping_tax_exc"], 2), 'currency' => $this->currency->iso_code), 'shippingDiscount' => array('amount' => $this->formatNumber(0, 2), 'currency' => $this->currency->iso_code), 'shippingTax' => array('amount' => $this->formatNumber($shipping_tax, 2), 'currency' => $this->currency->iso_code), 'tax' => array('amount' => $this->formatNumber($det["total_tax"], 2), 'currency' => $this->currency->iso_code), 'total' => array('amount' => $this->formatNumber($det["total_price"], 2), 'currency' => $this->currency->iso_code)), 'orderCostDetails' => $detail);
return $response;
}
示例12: hookDisplayLeftColumn
public function hookDisplayLeftColumn()
{
if ($this->context->controller->php_self == 'category') {
$this->context->controller->addJS(_PS_MODULE_DIR_ . $this->name . '/views/js/wkhotelfilterblock.js');
$this->context->controller->addCSS(_PS_MODULE_DIR_ . $this->name . '/views/css/wkhotelfilterblock.css');
$all_feat = FeatureCore::getFeatures($this->context->language->id);
$htl_id_category = Tools::getValue('id_category');
$id_hotel = HotelBranchInformation::getHotelIdByIdCategory($htl_id_category);
$max_adult = HotelRoomType::getMaxAdults($id_hotel);
$max_child = HotelRoomType::getMaxChild($id_hotel);
$category = new Category($htl_id_category);
if (!($date_from = Tools::getValue('date_from'))) {
$date_from = date('Y-m-d');
$date_to = date('Y-m-d', strtotime($date_from) + 86400);
}
if (!($date_to = Tools::getValue('date_to'))) {
$date_to = date('Y-m-d', strtotime($date_from) + 86400);
}
$obj_rm_type = new HotelRoomType();
$room_types = $obj_rm_type->getIdProductByHotelId($id_hotel);
$prod_price = array();
if ($room_types) {
foreach ($room_types as $key => $value) {
$prod_price[] = Product::getPriceStatic($value['id_product']);
}
}
if (Configuration::get('PS_REWRITING_SETTINGS')) {
$cat_link = $this->context->link->getCategoryLink($category) . '?date_from=' . $date_from . '&date_to=' . $date_to;
} else {
$cat_link = $this->context->link->getCategoryLink($category) . '&date_from=' . $date_from . '&date_to=' . $date_to;
}
$currency = $this->context->currency;
$config = $this->getConfigFieldsValues();
$obj_booking_detail = new HotelBookingDetail();
$num_days = $obj_booking_detail->getNumberOfDays($date_from, $date_to);
$ratting_img = _MODULE_DIR_ . $this->name . '/views/img/stars-sprite-image.png';
$this->context->smarty->assign(array('all_feat' => $all_feat, 'max_adult' => $max_adult, 'max_child' => $max_child, 'cat_link' => $cat_link, 'ratting_img' => $ratting_img, 'currency' => $currency, 'date_from' => $date_from, 'date_to' => $date_to, 'num_days' => $num_days, 'config' => $config, 'min_price' => $prod_price ? min($prod_price) : 0, 'max_price' => $prod_price ? max($prod_price) : 0));
return $this->display(__FILE__, 'htlfilterblock.tpl');
}
}
示例13: smartyAssigns
function smartyAssigns(&$smarty, &$params)
{
global $errors;
// Set currency
if (!intval($params['cart']->id_currency)) {
$currency = new Currency(intval($params['cookie']->id_currency));
} else {
$currency = new Currency(intval($params['cart']->id_currency));
}
if (!Validate::isLoadedObject($currency)) {
$currency = new Currency(intval(Configuration::get('PS_DEFAULT_CURRENCY')));
}
$products = $params['cart']->getProducts(true);
foreach ($products as $k => $product) {
$products[$k]['real_price'] = Product::getPriceStatic($product['id_product'], intval(Configuration::get('PS_PRICE_DISPLAY')) == 1 ? false : true, $product['id_product_attribute'], 6, NULL, false, true, $product['cart_quantity']) * $product['cart_quantity'];
}
$smarty->assign(array('products' => $products, 'customizedDatas' => Product::getAllCustomizedDatas(intval($params['cart']->id)), 'CUSTOMIZE_FILE' => _CUSTOMIZE_FILE_, 'CUSTOMIZE_TEXTFIELD' => _CUSTOMIZE_TEXTFIELD_, 'discounts' => $params['cart']->getDiscounts(false, true), 'nb_total_products' => $params['cart']->nbProducts(), 'shipping_cost' => Tools::displayPrice($params['cart']->getOrderTotal(intval(Configuration::get('PS_PRICE_DISPLAY')) == 1 ? false : true, 5), $currency), 'show_wrapping' => floatval($params['cart']->getOrderTotal(true, 6)) > 0 ? true : false, 'wrapping_cost' => Tools::displayPrice($params['cart']->getOrderTotal(intval(Configuration::get('PS_PRICE_DISPLAY')) == 1 ? false : true, 6), $currency), 'product_total' => Tools::displayPrice($params['cart']->getOrderTotal(intval(Configuration::get('PS_PRICE_DISPLAY')) == 1 ? false : true, 4), $currency), 'total' => Tools::displayPrice($params['cart']->getOrderTotal(intval(Configuration::get('PS_PRICE_DISPLAY')) == 1 ? false : true), $currency), 'id_carrier' => $params['cart']->id_carrier, 'ajax_allowed' => intval(Configuration::get('PS_BLOCK_CART_AJAX')) == 1 ? true : false));
if (sizeof($errors)) {
$smarty->assign('errors', $errors);
}
if (isset($params['cookie']->ajax_blockcart_display)) {
$smarty->assign('colapseExpandStatus', $params['cookie']->ajax_blockcart_display);
}
}
示例14: setDetailProductPrice
protected function setDetailProductPrice(Order $order, Cart $cart, $product)
{
$this->setContext((int) $product['id_shop']);
$specific_price = $null = null;
Product::getPriceStatic((int) $product['id_product'], true, (int) $product['id_product_attribute'], 6, null, false, true, array($product['cart_quantity'], $product['cart_quantity_fractional']), false, (int) $order->id_customer, (int) $order->id_cart, (int) $order->{Configuration::get('PS_TAX_ADDRESS_TYPE')}, $specific_price, true, true, $this->context);
$this->specificPrice = $specific_price;
$this->original_product_price = Product::getPriceStatic($product['id_product'], false, (int) $product['id_product_attribute'], 6, null, false, false, 1, false, null, null, null, $null, true, true, $this->context);
$this->product_price = $this->original_product_price;
$this->unit_price_tax_incl = (double) $product['price_wt'];
$this->unit_price_tax_excl = (double) $product['price'];
$this->total_price_tax_incl = (double) $product['total_wt'];
$this->total_price_tax_excl = (double) $product['total'];
$this->purchase_supplier_price = (double) $product['wholesale_price'];
if ($product['id_supplier'] > 0 && ($supplier_price = ProductSupplier::getProductPrice((int) $product['id_supplier'], $product['id_product'], $product['id_product_attribute'], true)) > 0) {
$this->purchase_supplier_price = (double) $supplier_price;
}
$this->setSpecificPrice($order, $product);
$this->group_reduction = (double) Group::getReduction((int) $order->id_customer);
$shop_id = $this->context->shop->id;
$quantity_discount = SpecificPrice::getQuantityDiscount((int) $product['id_product'], $shop_id, (int) $cart->id_currency, (int) $this->vat_address->id_country, (int) $this->customer->id_default_group, (int) PP::resolveQty($product['cart_quantity'], $product['cart_quantity_fractional']), false, null, null, $null, true, true, $this->context);
$unit_price = Product::getPriceStatic((int) $product['id_product'], true, $product['id_product_attribute'] ? (int) $product['id_product_attribute'] : null, 2, null, false, true, 1, false, (int) $order->id_customer, null, (int) $order->{Configuration::get('PS_TAX_ADDRESS_TYPE')}, $null, true, true, $this->context);
$this->product_quantity_discount = 0.0;
if ($quantity_discount) {
$this->product_quantity_discount = $unit_price;
if (Product::getTaxCalculationMethod((int) $order->id_customer) == PS_TAX_EXC) {
$this->product_quantity_discount = Tools::ps_round($unit_price, 2);
}
if (isset($this->tax_calculator)) {
$this->product_quantity_discount -= $this->tax_calculator->addTaxes($quantity_discount['price']);
}
}
$this->discount_quantity_applied = $this->specificPrice && $this->specificPrice['from_quantity'] > PP::getSpecificPriceFromQty((int) $product['id_product']) ? 1 : 0;
$this->id_cart_product = (int) $product['id_cart_product'];
$this->product_quantity_fractional = (double) $product['cart_quantity_fractional'];
$ppropertiessmartprice_hook3 = null;
}
示例15: orderbyPrice
public static function orderbyPrice(&$array, $order_way)
{
foreach ($array as &$row) {
$row['price_tmp'] = Product::getPriceStatic($row['id_product'], true, isset($row['id_product_attribute']) && !empty($row['id_product_attribute']) ? (int) $row['id_product_attribute'] : null, 2);
}
if (Tools::strtolower($order_way) == 'desc') {
uasort($array, 'cmpPriceDesc');
} else {
uasort($array, 'cmpPriceAsc');
}
foreach ($array as &$row) {
unset($row['price_tmp']);
}
}