Example #1
0
        ?>
</dd>
								<dt><?php 
        echo JText::_('COM_JEPROSHOP_VALID_ORDER_PLACED_LABEL') . ' : ';
        ?>
</dt>
								<dd><span class="badge badge-success"><?php 
        echo (int) $this->customerStats->nb_orders;
        ?>
</span></dd>
								<dt><?php 
        echo JText::_('COM_JEPROSHOP_TOTAL_SPENT_SINCE_REGISTRATION_LABEL') . ' : ';
        ?>
</dt>
								<dd><span class="badge badge-success"> <?php 
        echo JeproshopTools::displayPrice(JeproshopTools::roundPrice(JeproshopTools::convertPrice($this->customerStats->total_orders, $this->currency), 2), $this->currency->currency_id);
        ?>
</span></dd>
								<?php 
        if (JeproshopSettingModelSetting::getValue('enable_b2b_mode')) {
            ?>
								<dt><?php 
            echo JText::_('COM_JEPROSHOP_SIRET_LABEL') . ' : ';
            ?>
</dt>
								<dd><?php 
            echo $this->customer->siret;
            ?>
</dd>
								<dt><?php 
            echo JText::_('COM_JEPROSHOP_APE_LABEL') . ' : ';
Example #2
0
                    ?>
                                            <br /><?php 
                    echo JText::_('COM_JEPROSHOP_NOT_IMPACTED_BY_DISCOUNT_LABEL');
                    ?>
                                        <?php 
                }
                ?>
                                    </div>
                                </div>
                                <?php 
            }
            if (!empty($this->product->unity) && $this->product->unit_price_ratio > 0.0) {
                $unit_price = $product_price / $this->unit_price_ratio;
                ?>
                                    <p class="unit_price"><span id="jform_unit_price_display"><?php 
                JeproshopTools::convertPrice($unit_price);
                ?>
</span> <?php 
                echo JText::_('COM_JEPROSHOP_PER_LABEL') . ' ' . $this->product->unity;
                ?>
</p>
                                        <!-- {hook h="displayProductPriceBlock" product=$product type="unit_price"} -->
                                <?php 
            }
            ?>
                            </div>
                            <div class="product_attributes clearfix horizontal-form well">
                                <!-- quantity wanted -->
                                <?php 
            if (!$this->catalog_mode) {
                ?>
Example #3
0
 /**
  * Get total paid
  *
  * @since 1.5.0.1
  * @param JeproshopCurrencyModelCurrency $currency currency used for the total paid of the current order
  * @return float amount in the $currency
  */
 public function getTotalPaid($currency = null)
 {
     if (!$currency) {
         $currency = new JeproshopCurrencyModelCurrency($this->currency_id);
     }
     $total = 0;
     // Retrieve all payments
     $payments = $this->getOrderPaymentCollection();
     foreach ($payments as $payment) {
         if ($payment->currency_id == $currency->currency_id) {
             $total += $payment->amount;
         } else {
             $amount = JeproshopTools::convertPrice($payment->amount, $payment->currency_id, false);
             if ($currency->currency_id == JeproshopSettingModelSetting::getValue('default_currency', null, null, $this->shop_id)) {
                 $total += $amount;
             } else {
                 $total += JeproshopTools::convertPrice($amount, $currency->currency_id, true);
             }
         }
     }
     return JeproshopTools::roundPrice($total, 2);
 }
Example #4
0
 /**
  * This function returns the total cart amount
  *
  * Possible values for $type:
  * JeproshopCartModelCart::ONLY_PRODUCTS
  * JeproshopCartModelCart::ONLY_DISCOUNTS
  * JeproshopCartModelCart::BOTH
  * JeproshopCartModelCart::BOTH_WITHOUT_SHIPPING
  * JeproshopCartModelCart::ONLY_SHIPPING
  * JeproshopCartModelCart::ONLY_WRAPPING
  * JeproshopCartModelCart::ONLY_PRODUCTS_WITHOUT_SHIPPING
  * JeproshopCartModelCart::ONLY_PHYSICAL_PRODUCTS_WITHOUT_SHIPPING
  *
  * @param boolean $withTaxes With or without taxes
  * @param integer $type Total type
  * @param null $products
  * @param null $carrier_id
  * @param boolean $use_cache Allow using cache of the method CartRule::getContextualValue
  * @return float Order total
  */
 public function getOrderTotal($withTaxes = true, $type = JeproshopCartModelCart::BOTH, $products = null, $carrier_id = null, $use_cache = true)
 {
     if (!$this->cart_id) {
         return 0;
     }
     $type = (int) $type;
     $array_type = array(JeproshopCartModelCart::ONLY_PRODUCTS, JeproshopCartModelCart::ONLY_DISCOUNTS, JeproshopCartModelCart::BOTH, JeproshopCartModelCart::BOTH_WITHOUT_SHIPPING, JeproshopCartModelCart::ONLY_SHIPPING, JeproshopCartModelCart::ONLY_WRAPPING, JeproshopCartModelCart::ONLY_PRODUCTS_WITHOUT_SHIPPING, JeproshopCartModelCart::ONLY_PHYSICAL_PRODUCTS_WITHOUT_SHIPPING);
     // Define virtual context to prevent case where the cart is not the in the global context
     $virtual_context = JeproshopContext::getContext()->cloneContext();
     $virtual_context->cart = $this;
     if (!in_array($type, $array_type)) {
         die(Tools::displayError());
     }
     $with_shipping = in_array($type, array(JeproshopCartModelCart::BOTH, JeproshopCartModelCart::ONLY_SHIPPING));
     // if cart rules are not used
     if ($type == JeproshopCartModelCart::ONLY_DISCOUNTS && !JeproshopCartRuleModelCartRule::isFeaturePublished()) {
         return 0;
     }
     // no shipping cost if is a cart with only virtual products
     $virtual = $this->isVirtualCart();
     if ($virtual && $type == JeproshopCartModelCart::ONLY_SHIPPING) {
         return 0;
     }
     if ($virtual && $type == JeproshopCartModelCart::BOTH) {
         $type = JeproshopCartModelCart::BOTH_WITHOUT_SHIPPING;
     }
     if ($with_shipping || $type == JeproshopCartModelCart::ONLY_DISCOUNTS) {
         if (is_null($products) && is_null($carrier_id)) {
             $shipping_fees = $this->getTotalShippingCost(null, (bool) $withTaxes);
         } else {
             $shipping_fees = $this->getPackageShippingCost($carrier_id, (bool) $withTaxes, null, $products);
         }
     } else {
         $shipping_fees = 0;
     }
     if ($type == JeproshopCartModelCart::ONLY_SHIPPING) {
         return $shipping_fees;
     }
     if ($type == JeproshopCartModelCart::ONLY_PRODUCTS_WITHOUT_SHIPPING) {
         $type = JeproshopCartModelCart::ONLY_PRODUCTS;
     }
     $param_product = true;
     if (is_null($products)) {
         $param_product = false;
         $products = $this->getProducts();
     }
     if ($type == JeproshopCartModelCart::ONLY_PHYSICAL_PRODUCTS_WITHOUT_SHIPPING) {
         foreach ($products as $key => $product) {
             if ($product->is_virtual) {
                 unset($products[$key]);
             }
         }
         $type = JeproshopCartModelCart::ONLY_PRODUCTS;
     }
     $order_total = 0;
     if (JeproshopTaxModelTax::taxExcludedOption()) {
         $with_taxes = false;
     }
     foreach ($products as $product) {
         // products refer to the cart details
         if ($virtual_context->shop->shop_id != $product->shop_id) {
             $virtual_context->shop = new JeproshopShopModelShop((int) $product->shop_id);
         }
         if (JeproshopSettingModelSetting::getValue('PS_TAX_ADDRESS_TYPE') == 'address_invoice_id') {
             $address_id = (int) $this->address_invoice_id;
         } else {
             $address_id = (int) $product->address_delivery_id;
         }
         // Get delivery address of the product from the cart
         if (!JeproshopAddressModelAddress::addressExists($address_id)) {
             $address_id = null;
         }
         $null = null;
         if ($this->_taxCalculationMethod == COM_JEPROSHOP_TAX_EXCLUDED) {
             // Here taxes are computed only once the quantity has been applied to the product price
             $price = JeproshopProductModelProduct::getStaticPrice((int) $product->product_id, false, (int) $product->product_attribute_id, 2, null, false, true, $product->cart_quantity, false, (int) $this->customer_id ? (int) $this->customer_id : null, (int) $this->cart_id, $address_id, $null, true, true, $virtual_context);
             $total_ecotax = $product->ecotax * (int) $product->cart_quantity;
             $total_price = $price * (int) $product->cart_quantity;
             if ($withTaxes) {
                 $product_tax_rate = (double) JeproshopTaxModelTax::getProductTaxRate((int) $product->product_id, (int) $address_id, $virtual_context);
                 $product_eco_tax_rate = JeproshopTaxModelTax::getProductEcotaxRate((int) $address_id);
                 $total_price = ($total_price - $total_ecotax) * (1 + $product_tax_rate / 100);
                 $total_ecotax = $total_ecotax * (1 + $product_eco_tax_rate / 100);
                 $total_price = JeproshopTools::roundPrice($total_price + $total_ecotax, 2);
             }
         } else {
             if ($withTaxes) {
                 $price = JeproshopProductModelProduct::getStaticPrice((int) $product->product_id, true, (int) $product->product_attribute_id, 2, null, false, true, $product->cart_quantity, false, (int) $this->customer_id ? (int) $this->customer_id : null, (int) $this->cart_id, (int) $address_id ? (int) $address_id : null, $null, true, true, $virtual_context);
             } else {
                 $price = JeproshopProductModelProduct::getStaticPrice((int) $product->product_id, false, (int) $product->product_attribute_id, 2, null, false, true, $product->cart_quantity, false, (int) $this->customer_id ? (int) $this->customer_id : null, (int) $this->cart_id, (int) $address_id ? (int) $address_id : null, $null, true, true, $virtual_context);
             }
             $total_price = JeproshopTools::roundPrice($price * (int) $product->cart_quantity, 2);
         }
         $order_total += $total_price;
     }
     $order_total_products = $order_total;
     if ($type == JeproshopCartModelCart::ONLY_DISCOUNTS) {
         $order_total = 0;
     }
     // Wrapping Fees
     $wrapping_fees = 0;
     if ($this->gift) {
         $wrapping_fees = JeproshopTools::convertPrice(JeproshopTools::roundPrice($this->getGiftWrappingPrice($withTaxes), 2), JeproshopCurrencyModelCurrency::getCurrencyInstance((int) $this->currency_id));
     }
     if ($type == JeproshopCartModelCart::ONLY_WRAPPING) {
         return $wrapping_fees;
     }
     $order_total_discount = 0;
     if (!in_array($type, array(JeproshopCartModelCart::ONLY_SHIPPING, JeproshopCartModelCart::ONLY_PRODUCTS)) && JeproshopCartRuleModelCartRule::isFeaturePublished()) {
         // First, retrieve the cart rules associated to this "getOrderTotal"
         if ($with_shipping || $type == JeproshopCartModelCart::ONLY_DISCOUNTS) {
             $cart_rules = $this->getCartRules(JeproshopCartRuleModelCartRule::FILTER_ACTION_ALL);
         } else {
             $cart_rules = $this->getCartRules(CartRule::FILTER_ACTION_REDUCTION);
             // Cart Rules array are merged manually in order to avoid doubles
             foreach ($this->getCartRules(JeproshopCartRuleModelCartRule::FILTER_ACTION_GIFT) as $tmp_cart_rule) {
                 $flag = false;
                 foreach ($cart_rules as $cart_rule) {
                     if ($tmp_cart_rule->cart_rule_id == $cart_rule->cart_rule_id) {
                         $flag = true;
                     }
                 }
                 if (!$flag) {
                     $cart_rules[] = $tmp_cart_rule;
                 }
             }
         }
         $id_address_delivery = 0;
         if (isset($products[0])) {
             $id_address_delivery = is_null($products) ? $this->address_delivery_id : $products[0]->address_delivery_id;
         }
         $package = array('id_carrier' => $carrier_id, 'id_address' => $id_address_delivery, 'products' => $products);
         // Then, calculate the contextual value for each one
         foreach ($cart_rules as $cart_rule) {
             // If the cart rule offers free shipping, add the shipping cost
             if (($with_shipping || $type == Cart::ONLY_DISCOUNTS) && $cart_rule['obj']->free_shipping) {
                 $order_total_discount += Tools::ps_round($cart_rule['obj']->getContextualValue($with_taxes, $virtual_context, CartRule::FILTER_ACTION_SHIPPING, $param_product ? $package : null, $use_cache), 2);
             }
             // If the cart rule is a free gift, then add the free gift value only if the gift is in this package
             if ((int) $cart_rule['obj']->gift_product) {
                 $in_order = false;
                 if (is_null($products)) {
                     $in_order = true;
                 } else {
                     foreach ($products as $product) {
                         if ($cart_rule['obj']->gift_product == $product['id_product'] && $cart_rule['obj']->gift_product_attribute == $product['id_product_attribute']) {
                             $in_order = true;
                         }
                     }
                 }
                 if ($in_order) {
                     $order_total_discount += $cart_rule['obj']->getContextualValue($with_taxes, $virtual_context, CartRule::FILTER_ACTION_GIFT, $package, $use_cache);
                 }
             }
             // If the cart rule offers a reduction, the amount is prorated (with the products in the package)
             if ($cart_rule['obj']->reduction_percent > 0 || $cart_rule['obj']->reduction_amount > 0) {
                 $order_total_discount += Tools::ps_round($cart_rule['obj']->getContextualValue($with_taxes, $virtual_context, CartRule::FILTER_ACTION_REDUCTION, $package, $use_cache), 2);
             }
         }
         $order_total_discount = min(JeproshopTools::roundPrice($order_total_discount, 2), $wrapping_fees + $order_total_products + $shipping_fees);
         $order_total -= $order_total_discount;
     }
     if ($type == JeproshopCartModelCart::BOTH) {
         $order_total += $shipping_fees + $wrapping_fees;
     }
     if ($order_total < 0 && $type != JeproshopCartModelCart::ONLY_DISCOUNTS) {
         return 0;
     }
     if ($type == JeproshopCartModelCart::ONLY_DISCOUNTS) {
         return $order_total_discount;
     }
     return JeproshopTools::roundPrice((double) $order_total, 2);
 }
Example #5
0
            echo JeproshopTools::convertPrice($product_price - (double) ($product_price * $quantity_discount->reduction));
        } else {
            echo $quantity_discount->real_value . '%';
        }
    }
    ?>
                </td>
                <td>
                    <span><?php 
    echo JText::_('COM_JEPROSHOP_UP_TO_LABEL');
    ?>
</span>
                    <?php 
    if ($this->quantity_discount->price >= 0 || $this->quantity_discount->reduction_type == 'amount') {
        $discountPrice = $product_price - (double) $this->quantity_discount->real_value;
    } else {
        $discountPrice = $product_price - (double) ($product_price * $this->quantity_discount->reduction);
    }
    $discountPrice = $discountPrice * $this->quantity_discount->quantity;
    $qtyProductPrice = $product_price * $this->quantity_discount->quantity;
    echo JeproshopTools::convertPrice($qtyProductPrice - $discountPrice);
    ?>
                </td>
            </tr>
            <?php 
}
?>
        </tbody>
    </table>
</div>
<!-- quantity discount -->
Example #6
0
 /**
  * Price calculation / Get product price
  *
  * @param integer $shop_id Shop id
  * @param integer $product_id Product id
  * @param integer $product_attribute_id Product attribute id
  * @param integer $country_id Country id
  * @param integer $state_id State id
  * @param $zipcode
  * @param integer $currency_id Currency id
  * @param integer $group_id Group id
  * @param integer $quantity Quantity Required for Specific prices : quantity discount application
  * @param boolean $use_tax with (1) or without (0) tax
  * @param integer $decimals Number of decimals returned
  * @param boolean $only_reduction Returns only the reduction amount
  * @param boolean $use_reduction Set if the returned amount will include reduction
  * @param boolean $with_ecotax insert ecotax in price output.
  * @param $specific_price
  * @param $use_group_reduction
  * @param int $customer_id
  * @param bool $use_customer_price
  * @param int $cart_id
  * @param int $real_quantity
  * @internal param \variable_reference $specific_price_output If a specific price applies regarding the previous parameters, this variable is filled with the corresponding SpecificPrice object*    If a specific price applies regarding the previous parameters, this variable is filled with the corresponding SpecificPrice object
  * @return float Product price
  */
 public static function priceCalculation($shop_id, $product_id, $product_attribute_id, $country_id, $state_id, $zipcode, $currency_id, $group_id, $quantity, $use_tax, $decimals, $only_reduction, $use_reduction, $with_ecotax, &$specific_price, $use_group_reduction, $customer_id = 0, $use_customer_price = true, $cart_id = 0, $real_quantity = 0)
 {
     static $address = null;
     static $context = null;
     if ($address === null) {
         $address = new JeproshopAddressModelAddress();
     }
     if ($context == null) {
         $context = JeproshopContext::getContext()->cloneContext();
     }
     if ($shop_id !== null && $context->shop->shop_id != (int) $shop_id) {
         $context->shop = new JeproshopShopModelShop((int) $shop_id);
     }
     if (!$use_customer_price) {
         $customer_id = 0;
     }
     if ($product_attribute_id === null) {
         $product_attribute_id = JeproshopProductModelProduct::getDefaultAttribute($product_id);
     }
     $cache_id = $product_id . '_' . $shop_id . '_' . $currency_id . '_' . $country_id . '_' . $state_id . '_' . $zipcode . '_' . $group_id . '_' . $quantity . '_' . $product_attribute_id . '_' . ($use_tax ? '1' : '0') . '_' . $decimals . '_' . ($only_reduction ? '1' : '0') . '_' . ($use_reduction ? '1' : '0') . '_' . $with_ecotax . '_' . $customer_id . '_' . (int) $use_group_reduction . '_' . (int) $cart_id . '-' . (int) $real_quantity;
     // reference parameter is filled before any returns
     $specific_price = JeproshopSpecificPriceModelSpecificPrice::getSpecificPrice((int) $product_id, $shop_id, $currency_id, $country_id, $group_id, $quantity, $product_attribute_id, $customer_id, $cart_id, $real_quantity);
     if (isset(self::$_prices[$cache_id])) {
         return self::$_prices[$cache_id];
     }
     $db = JFactory::getDBO();
     // fetch price & attribute price
     $cache_id_2 = $product_id . '-' . $shop_id;
     if (!isset(self::$_pricesLevel2[$cache_id_2])) {
         $select = "SELECT product_shop." . $db->quoteName('price') . ", product_shop." . $db->quoteName('ecotax');
         $from = $db->quoteName('#__jeproshop_product') . " AS product INNER JOIN " . $db->quoteName('#__jeproshop_product_shop');
         $from .= " AS product_shop ON (product_shop.product_id =product.product_id AND product_shop.shop_id = " . (int) $shop_id . ")";
         if (JeproshopCombinationModelCombination::isFeaturePublished()) {
             $select .= ", product_attribute_shop.product_attribute_id, product_attribute_shop." . $db->quoteName('price') . " AS attribute_price, product_attribute_shop.default_on";
             $leftJoin = " LEFT JOIN " . $db->quoteName('#__jeproshop_product_attribute') . " AS product_attribute ON product_attribute.";
             $leftJoin .= $db->quoteName('product_id') . " = product." . $db->quoteName('product_id') . " LEFT JOIN " . $db->quoteName('#__jeproshop_product_attribute_shop');
             $leftJoin .= " AS product_attribute_shop ON (product_attribute_shop.product_attribute_id = product_attribute.product_attribute_id AND product_attribute_shop.shop_id = " . (int) $shop_id . ")";
         } else {
             $select .= ", 0 as product_attribute_id";
             $leftJoin = "";
         }
         $query = $select . " FROM " . $from . $leftJoin . " WHERE product." . $db->quoteName('product_id') . " = " . (int) $product_id;
         $db->setQuery($query);
         $results = $db->loadObjectList();
         foreach ($results as $row) {
             $array_tmp = array('price' => $row->price, 'ecotax' => $row->ecotax, 'attribute_price' => isset($row->attribute_price) ? $row->attribute_price : null);
             self::$_pricesLevel2[$cache_id_2][(int) $row->product_attribute_id] = $array_tmp;
             if (isset($row->default_on) && $row->default_on == 1) {
                 self::$_pricesLevel2[$cache_id_2][0] = $array_tmp;
             }
         }
     }
     if (!isset(self::$_pricesLevel2[$cache_id_2][(int) $product_attribute_id])) {
         return;
     }
     $result = self::$_pricesLevel2[$cache_id_2][(int) $product_attribute_id];
     if (!$specific_price || $specific_price->price < 0) {
         $price = (double) $result['price'];
     } else {
         $price = (double) $specific_price->price;
     }
     // convert only if the specific price is in the default currency (id_currency = 0)
     if (!$specific_price || !($specific_price->price >= 0 && $specific_price->currency_id)) {
         $price = JeproshopTools::convertPrice($price, $currency_id);
     }
     // Attribute price
     if (is_array($result) && (!$specific_price || !$specific_price->product_attribute_id || $specific_price->price < 0)) {
         $attribute_price = JeproshopTools::convertPrice($result['attribute_price'] !== null ? (double) $result['attribute_price'] : 0, $currency_id);
         // If you want the default combination, please use NULL value instead
         if ($product_attribute_id !== false) {
             $price += $attribute_price;
         }
     }
     // Tax
     $address->country_id = $country_id;
     $address->state_id = $state_id;
     $address->postcode = $zipcode;
     $tax_manager = JeproshopTaxManagerFactory::getManager($address, JeproshopProductModelProduct::getTaxRulesGroupIdByProductId((int) $product_id, $context));
     $product_tax_calculator = $tax_manager->getTaxCalculator();
     // Add Tax
     if ($use_tax) {
         $price = $product_tax_calculator->addTaxes($price);
     }
     // Reduction
     $specific_price_reduction = 0;
     if (($only_reduction || $use_reduction) && $specific_price) {
         if ($specific_price->reduction_type == 'amount') {
             $reduction_amount = $specific_price->reduction;
             if (!$specific_price->currency_id) {
                 $reduction_amount = JeproshopTools::convertPrice($reduction_amount, $currency_id);
             }
             $specific_price_reduction = !$use_tax ? $product_tax_calculator->removeTaxes($reduction_amount) : $reduction_amount;
         } else {
             $specific_price_reduction = $price * $specific_price->reduction;
         }
     }
     if ($use_reduction) {
         $price -= $specific_price_reduction;
     }
     // Group reduction
     if ($use_group_reduction) {
         $reduction_from_category = JeproshopGroupReductionModelGroupReduction::getValueForProduct($product_id, $group_id);
         if ($reduction_from_category !== false) {
             $group_reduction = $price * (double) $reduction_from_category;
         } else {
             // apply group reduction if there is no group reduction for this category
             $group_reduction = ($reduction = JeproshopGroupModelGroup::getReductionByGroupId($group_id)) != 0 ? $price * $reduction / 100 : 0;
         }
     } else {
         $group_reduction = 0;
     }
     if ($only_reduction) {
         return JeproshopTools::roundPrice($group_reduction + $specific_price_reduction, $decimals);
     }
     if ($use_reduction) {
         $price -= $group_reduction;
     }
     // Eco Tax
     if (($result['ecotax'] || isset($result['attribute_ecotax'])) && $with_ecotax) {
         $ecotax = $result['ecotax'];
         if (isset($result['attribute_ecotax']) && $result['attribute_ecotax'] > 0) {
             $ecotax = $result['attribute_ecotax'];
         }
         if ($currency_id) {
             $ecotax = JeproshopTools::convertPrice($ecotax, $currency_id);
         }
         if ($use_tax) {
             // reinit the tax manager for ecotax handling
             $tax_manager = JeproshopTaxManagerFactory::getManager($address, (int) JeproshopSettingModelSetting::getValue('ecotax_tax_rules_group_id'));
             $ecotax_tax_calculator = $tax_manager->getTaxCalculator();
             $price += $ecotax_tax_calculator->addTaxes($ecotax);
         } else {
             $price += $ecotax;
         }
     }
     $price = JeproshopTools::roundPrice($price, $decimals);
     if ($price < 0) {
         $price = 0;
     }
     self::$_prices[$cache_id] = $price;
     return self::$_prices[$cache_id];
 }
Example #7
0
 /**
  * Assign price and tax to the template
  */
 protected function assignPriceAndTax()
 {
     $customer_id = isset($this->context->customer) ? (int) $this->context->customer->customer_id : 0;
     $group_id = (int) JeproshopGroupModelGroup::getCurrent()->group_id;
     $country_id = (int) $customer_id ? JeproshopCustomerModelCustomer::getCurrentCountry($customer_id) : JeproshopSettingModelSetting::getValue('default_country');
     $group_reduction = JeproshopGroupReductionModelGroupReduction::getValueForProduct($this->product->product_id, $group_id);
     if ($group_reduction === false) {
         $group_reduction = JeproshopGroupModelGroup::getReduction((int) $this->context->cookie->customer_id) / 100;
     }
     // Tax
     $tax = (double) $this->product->getTaxesRate(new JeproshopAddressModelAddress((int) $this->context->cart->{JeproshopSettingModelSetting::getValue('tax_address_type')}));
     $this->assignRef('tax_rate', $tax);
     $product_price_with_tax = JeproshopProductModelProduct::getStaticPrice($this->product->product_id, true, null, 6);
     if (JeproshopProductModelProduct::$_taxCalculationMethod == COM_JEPROSHOP_TAX_INCLUDED) {
         $product_price_with_tax = JeproshopTools::roundPrice($product_price_with_tax, 2);
     }
     $product_price_without_eco_tax = (double) $product_price_with_tax - $this->product->ecotax;
     $ecotax_rate = (double) JeproshopTaxModelTax::getProductEcotaxRate($this->context->cart->{JeproshopSettingModelSetting::getValue('tax_address_type')});
     $ecotax_tax_amount = JeproshopTools::roundPrice($this->product->ecotax, 2);
     if (JeproshopProductModelProduct::$_taxCalculationMethod == COM_JEPROSHOP_TAX_INCLUDED && (int) JeproshopSettingModelSetting::getValue('use_tax')) {
         $ecotax_tax_amount = JeproshopTools::roundPrice($ecotax_tax_amount * (1 + $ecotax_rate / 100), 2);
     }
     $currency_id = (int) $this->context->cookie->currency_id;
     $product_id = (int) $this->product->product_id;
     $shop_id = $this->context->shop->shop_id;
     $quantity_discounts = JeproshopSpecificPriceModelSpecificPrice::getQuantityDiscounts($product_id, $shop_id, $currency_id, $country_id, $group_id, null, true, (int) $this->context->customer->customer_id);
     foreach ($quantity_discounts as &$quantity_discount) {
         if ($quantity_discount->product_attribute_id) {
             $combination = new JeproshopCombinationModelCombination((int) $quantity_discount->product_attribute_id);
             $attributes = $combination->getAttributesName((int) $this->context->language->lang_id);
             foreach ($attributes as $attribute) {
                 $quantity_discount->attributes = $attribute->name . ' - ';
             }
             $quantity_discount->attributes = rtrim($quantity_discount->attributes, ' - ');
         }
         if ((int) $quantity_discount->currency_id == 0 && $quantity_discount->reduction_type == 'amount') {
             $quantity_discount->reduction = JeproshopTools::convertPriceFull($quantity_discount->reduction, null, JeproshopContext::getContext()->currency);
         }
     }
     $product_price = $this->product->getPrice(JeproshopProductModelProduct::$_taxCalculationMethod == COM_JEPROSHOP_TAX_INCLUDED, false);
     $address = new JeproshopAddressModelAddress($this->context->cart->{JeproshopSettingModelSetting::getValue('tax_address_type')});
     $quantity_discounts = $this->formatQuantityDiscounts($quantity_discounts, $product_price, (double) $tax, $ecotax_tax_amount);
     $this->assignRef('quantity_discounts', $quantity_discounts);
     $this->assignRef('ecotax_tax_included', $ecotax_tax_amount);
     $ecotax_tax_excluded = JeproshopTools::roundPrice($this->product->ecotax, 2);
     $this->assignRef('ecotax_tax_excluded', $ecotax_tax_excluded);
     $this->assignRef('ecotaxTax_rate', $ecotax_rate);
     $display_price = JeproshopSettingModelSetting::getValue('display_price');
     $this->assignRef('display_price', $display_price);
     $product_price_without_eco_tax = (double) $product_price_without_eco_tax;
     $this->assignRef('product_price_without_ecotax', $product_price_without_eco_tax);
     $this->assignRef('group_reduction', $group_reduction);
     $no_tax = JeproshopTaxModelTax::taxExcludedOption() || !$this->product->getTaxesRate($address);
     $this->assignRef('no_tax', $no_tax);
     $ecotax = !count($this->errors) && $this->product->ecotax > 0 ? JeproshopTools::convertPrice((double) $this->product->ecotax) : 0;
     $this->assignRef('ecotax', $ecotax);
     $tax_enabled = JeproshopSettingModelSetting::getValue('use_tax');
     $this->assignRef('tax_enabled', $tax_enabled);
     $customer_group_without_tax = JeproshopGroupModelGroup::getPriceDisplayMethod($this->context->customer->default_group_id);
     $this->assignRef('customer_group_without_tax', $customer_group_without_tax);
 }
Example #8
0
?>
</label>
                    </div>
                    <div class="controls">
                        <div class="input-append" >
                            <?php 
if ($this->currency->prefix != "") {
    ?>
<button type="button" class="btn" id="jform_img" ><?php 
    echo $this->currency->prefix;
    ?>
</button><?php 
}
?>
                            <input type="text" maxlength="14" name="price_field[wholesale_price]" id="jform_wholesale_price" value="<?php 
echo JeproshopTools::convertPrice($this->product->wholesale_price);
?>
" onchange=" this.value.replace(/,/g,'.');" class="price_box" />
                            <?php 
if ($this->currency->suffix != "") {
    ?>
<button type="button" class="btn" id="jform_img" ><?php 
    echo $this->currency->suffix;
    ?>
</button><?php 
}
?>
                        </div>
                        <p class="field_description"><?php 
echo JText::_('COM_JEPROSHOP_PRODUCT_WHOLE_SALE_PRICE_DESCRIPTION');
?>
Example #9
0
 private function initPriceForm()
 {
     if ($this->context == null) {
         $this->context = JeproshopContext::getContext();
     }
     if ($this->product->product_id) {
         $shops = JeproshopShopModelShop::getShops();
         $countries = JeproshopCountryModelCountry::getStaticCountries($this->context->language->lang_id);
         $groups = JeproshopGroupModelGroup::getStaticGroups($this->context->language->lang_id);
         $currencies = JeproshopCurrencyModelCurrency::getStaticCurrencies();
         $attributes = $this->product->getAttributesGroups((int) $this->context->language->lang_id);
         $combinations = array();
         if (count($attributes)) {
             foreach ($attributes as $attribute) {
                 $combinations[$attribute->product_attribute_id] = new JObject();
                 $combinations[$attribute->product_attribute_id]->product_attribute_id = $attribute->product_attribute_id;
                 if (!isset($combinations[$attribute->product_attribute_id]->attributes)) {
                     $combinations[$attribute->product_attribute_id]->attributes = '';
                 }
                 if (isset($combinations[$attribute->product_attribute_id])) {
                     $combinations[$attribute->product_attribute_id]->attributes .= $attribute->attribute_name . ' - ';
                     $combinations[$attribute->product_attribute_id]->price = JeproshopTools::displayPrice(JeproshopTools::convertPrice(JeproshopProductModelProduct::getStaticPrice((int) $this->product->product_id, false, $attribute->product_attribute_id), $this->context->currency), $this->context->currency);
                 }
             }
             foreach ($combinations as $combination) {
                 if (isset($combination->attributes)) {
                     $combination->attributes = rtrim($combination->attributes, ' - ');
                 }
             }
         }
         $specificPriceModificationForm = $this->displaySpecificPriceModificationForm($this->context->currency, $shops, $currencies, $countries, $groups);
         $this->assignRef('specific_price_modification_form', $specificPriceModificationForm);
         $this->assignRef('ecotax_tax_excluded', $this->product->ecotax);
         //$this->applyTaxToEcotax();
         $this->assignRef('shops', $shops);
         /*$admin_one_shop = count($this->context->employee->getAssociatedShops()) == 1;
           $this->assignRef('admin_one_shop', $admin_one_shop); */
         $this->assignRef('currencies', $currencies);
         $this->assignRef('currency', $this->context->currency);
         $this->assignRef('countries', $countries);
         $this->assignRef('groups', $groups);
         $this->assignRef('combinations', $combinations);
         $multiShop = JeproshopShopModelShop::isFeaturePublished();
         $this->assignRef('multi_shop', $multiShop);
     } else {
         JError::raiseWarnig(JText::_('COM_JEPROSHOP_YOU_MUST_SAVE_THIS_PRODUCT_BEFORE_ADDING_SPECIFIC_PRICING_MESSAGE'));
         $this->product->tax_rules_group_id = JeproshopProductModelProduct::getTaxRulesMostUsedGroupId();
         $this->assignRef('ecotax_tax_excluded', 0);
     }
     $use_tax = JeproshopSettingModelSetting::getValue('use_tax');
     $this->assignRef('use_tax', $use_tax);
     $use_ecotax = JeproshopSettingModelSetting::getValue('use_eco_tax');
     $this->assignRef('use_ecotax', $use_ecotax);
     $tax_rules_groups = JeproshopTaxRulesGroupModelTaxRulesGroup::getTaxRulesGroups(true);
     $this->assignRef('tax_rules_groups', $tax_rules_groups);
     $taxesRatesByGroup = JeproshopTaxRulesGroupModelTaxRulesGroup::getAssociatedTaxRatesByCountryId($this->context->country->country_id);
     $this->assignRef('taxesRatesByGroup', $taxesRatesByGroup);
     $ecotaxTaxRate = JeproshopTaxModelTax::getProductEcotaxRate();
     $this->assignRef('ecotaxTaxRate', $ecotaxTaxRate);
     $tax_exclude_tax_option = JeproshopTaxModelTax::taxExcludedOption();
     $this->assignRef('tax_exclude_tax_option', $tax_exclude_tax_option);
     $this->product->price = JeproshopTools::convertPrice($this->product->price, $this->context->currency, true, $this->context);
     if ($this->product->unit_price_ratio != 0) {
         $unit_price = JeproshopTools::roundPrice($this->product->price / $this->product->unit_price_ratio, 2);
     } else {
         $unit_price = 0;
     }
     $this->assignRef('unit_price', $unit_price);
 }
Example #10
0
        echo substr(strip_tags($product->short_description), 0, 360);
        ?>
</p>
                    <?php 
        if (!$this->catalog_mode and isset($product->show_price) && $product->show_price || isset($product->available_for_order) && $product->available_for_order) {
            ?>
                    <div itemprop="offers" itemscope itemtype="http://schema.org/Offer" class="content-price">
                        <?php 
            if (isset($product->show_price) && $product->show_price && !isset($this->restricted_country_mode)) {
                ?>
						<span itemprop="price" class="price product-price">
						    <?php 
                if (!$this->display_price) {
                    echo JeproshopTools::convertPrice($product->price);
                } else {
                    echo JeproshopTools::convertPrice($product->price_tax_exc);
                }
                ?>
						</span>
                        <meta itemprop="priceCurrency" content="<?php 
                echo $this->currency->iso_code;
                ?>
" />
                        <?php 
                if (isset($product->specific_prices) && $product->specific_prices && isset($product->specific_prices->reduction) && $product->specific_prices->reduction > 0) {
                    ?>
                        <?php 
                    /* {hook h="displayProductPriceBlock" product=$product type="old_price"} */
                    ?>
						<span class="old-price product-price"><?php 
                    echo JeproshopTools::displayPrice($product->price_without_reduction, $this->context->currency);