Example #1
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 JeproshopValidator::convertPrice($product->price);
            } else {
                echo JeproshopValidator::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 JeproshopValidator::displayPriceWithoutReduction($product->price_without_reduction);
Example #2
0
 /**
  * Check delivery prices for a given order
  *
  * @param id_carrier
  * @param float $orderTotal Order total to pay
  * @param integer $zone_id Zone id (for customer delivery address)
  * @param integer $currency_id
  * @return float Delivery price
  */
 public static function checkDeliveryPriceByPrice($carrier_id, $orderTotal, $zone_id, $currency_id = null)
 {
     $cache_key = $carrier_id . '_' . $orderTotal . '_' . $zone_id . '_' . $currency_id;
     if (!isset(self::$price_by_price2[$cache_key])) {
         if (!empty($currency_id)) {
             $orderTotal = JeproshopValidator::convertPrice($orderTotal, $currency_id, false);
         }
         $db = JFactory::getDBO();
         $query = "SELECT d." . $db->quoteName('price') . " FROM " . $db->quoteName('#__jeproshop_delivery') . " AS delivery LEFT JOIN ";
         $query .= $db->quoteName('#__jeproshop_range_price') . " AS price_range ON delivery." . $db->quoteName('range_price_id') . " = range_price.";
         $query .= $db->quoteName('range_price_id') . " WHERE delivery." . $db->quoteName('zone_id') . " = " . (int) $zone_id . " AND " . (double) $orderTotal;
         $query .= " >= price_range." . $db->quoteName('delimiter1') . " AND " . (double) $orderTotal . " < price_range." . $db->quoteName('delimiter2');
         $query .= " AND delivery." . $db->quoteName('carrier_id') . " = " . (int) $carrier_id . JeproshopCarrierModelCarrier::sqlDeliveryRangeShop('range_price');
         $query .= " ORDER BY price_range." . $db->quoteName('delimiter1') . " ASC";
         $db->setQuery($query);
         $result = $db->loadObject();
         self::$price_by_price2[$cache_key] = isset($result->price);
     }
     return self::$price_by_price2[$cache_key];
 }
Example #3
0
 /**
  * Return package shipping cost
  *
  * @param integer $carrier_id Carrier ID (default : current carrier)
  * @param boolean $use_tax
  * @param JeproshopCountryModelCountry $default_country
  * @param Array $product_list
  * @param array $product_list List of product concerned by the shipping. If null, all the product of the cart are used to calculate the shipping cost
  *
  * @return float Shipping total
  */
 public function getPackageShippingCost($carrier_id = null, $use_tax = true, JeproshopCountryModelCountry $default_country = null, $product_list = null, $zone_id = null)
 {
     if ($this->isVirtualCart()) {
         return 0;
     }
     if (!$default_country) {
         $default_country = JeproshopContext::getContext()->country;
     }
     $complete_product_list = $this->getProducts();
     if (is_null($product_list)) {
         $products = $complete_product_list;
     } else {
         $products = $product_list;
     }
     if (JeproshopSettingModelSetting::getValue('tax_address_type') == 'address_invoice_id') {
         $address_id = (int) $this->address_invoice_id;
     } elseif (count($product_list)) {
         $prod = current($product_list);
         $address_id = (int) $prod->address_delivery_id;
     } else {
         $address_id = null;
     }
     if (!JeproshopAddressModelAddress::addressExists($address_id)) {
         $address_id = null;
     }
     $cache_id = 'get_package_shipping_cost_' . (int) $this->cart_id . '_' . (int) $address_id . '_' . (int) $carrier_id . '_' . (int) $use_tax . '_' . (int) $default_country->country_id;
     if ($products) {
         foreach ($products as $product) {
             $cache_id .= '_' . (int) $product->product_id . '_' . (int) $product->product_attribute_id;
         }
     }
     if (JeproshopCache::isStored($cache_id)) {
         return JeproshopCache::retrieve($cache_id);
     }
     // Order total in default currency without fees
     $order_total = $this->getOrderTotal(true, JeproshopCartModelCart::ONLY_PHYSICAL_PRODUCTS_WITHOUT_SHIPPING, $product_list);
     // Start with shipping cost at 0
     $shipping_cost = 0;
     // If no product added, return 0
     if (!count($products)) {
         JeproshopCache::store($cache_id, $shipping_cost);
         return $shipping_cost;
     }
     if (!isset($zone_id)) {
         // Get id zone
         if (!$this->isMultiAddressDelivery() && isset($this->address_delivery_id) && $this->address_delivery_id && JeproshopCustomerModelCustomer::customerHasAddress($this->customer_id, $this->address_delivery_id)) {
             $zone_id = JeproshopAddressModelAddress::getZoneIdByAddressId((int) $this->address_delivery_id);
         } else {
             if (!JeproshopValidator::isLoadedObject($default_country, 'country_id')) {
                 $default_country = new Country(JeproshopSettingModelSeting::getValue('PS_COUNTRY_DEFAULT'), JeproshopSettingModelSeting::getValue('PS_LANG_DEFAULT'));
             }
             $zone_id = (int) $default_country->zone_id;
         }
     }
     if ($carrier_id && !$this->isCarrierInRange((int) $carrier_id, (int) $zone_id)) {
         $carrier_id = '';
     }
     if (empty($carrier_id) && $this->isCarrierInRange((int) JeproshopSettingModelSeting::getValue('default_carrier'), (int) $zone_id)) {
         $carrier_id = (int) JeproshopSettingModelSeting::getValue('default_carrier');
     }
     $total_package_without_shipping_tax_inc = $this->getOrderTotal(true, Cart::BOTH_WITHOUT_SHIPPING, $product_list);
     if (empty($carrier_id)) {
         if ((int) $this->customer_id) {
             $customer = new JeproshopCustomerModelCustomer((int) $this->customer_id);
             $result = JeproshopCarrierModelCarrier::getCarriers((int) JeproshopSettingModelSeting::getValue('default_lang'), true, false, (int) $zone_id, $customer->getGroups());
             unset($customer);
         } else {
             $result = JeproshopCarrierModelCarrier::getCarriers((int) JeproshopSettingModelSeting::getValue('default_lang'), true, false, (int) $zone_id);
         }
         foreach ($result as $k => $row) {
             if ($row->carrier_id == JeproshopSettingModelSeting::getValue('default_carrier')) {
                 continue;
             }
             if (!isset(self::$_carriers[$row->carrier_id])) {
                 self::$_carriers[$row->carrier_id] = new JeproshopCarrierModelCarrier((int) $row->carrier_id);
             }
             $carrier = self::$_carriers[$row->carrier_id];
             // Get only carriers that are compliant with shipping method
             if ($carrier->getShippingMethod() == JeproshopCarrierModelCarrier::WEIGHT_SHIPPING_METHOD && $carrier->getMaxDeliveryPriceByWeight((int) $zone_id) === false || $carrier->getShippingMethod() == JeproshopCarrierModelCarrier::PRICE_SHIPPING_METHOD && $carrier->getMaxDeliveryPriceByPrice((int) $zone_id) === false) {
                 unset($result[$k]);
                 continue;
             }
             // If out-of-range behavior carrier is set on "Deactivated carrier"
             if ($row->range_behavior) {
                 $check_delivery_price_by_weight = JeproshopCarrierModelCarrier::checkDeliveryPriceByWeight($row->carrier_id, $this->getTotalWeight(), (int) $zone_id);
                 $total_order = $total_package_without_shipping_tax_inc;
                 $check_delivery_price_by_price = JeproshopCarrierModelCarrier::checkDeliveryPriceByPrice($row->carrier_id, $total_order, (int) $zone_id, (int) $this->currency_id);
                 // Get only carriers that have a range compatible with cart
                 if ($carrier->getShippingMethod() == JeproshopCarrierModelCarrier::WEIGHT_SHIPPING_METHOD && !$check_delivery_price_by_weight || $carrier->getShippingMethod() == JeproshopCarrierModelCarrier::PRICE_SHIPPING_METHOD && !$check_delivery_price_by_price) {
                     unset($result[$k]);
                     continue;
                 }
             }
             if ($carrier->getShippingMethod() == JeproshopCarrierModelCarrier::WEIGHT_SHIPPING_METHOD) {
                 $shipping = $carrier->getDeliveryPriceByWeight($this->getTotalWeight($product_list), (int) $zone_id);
             } else {
                 $shipping = $carrier->getDeliveryPriceByPrice($order_total, (int) $zone_id, (int) $this->currency_id);
             }
             if (!isset($min_shipping_price)) {
                 $min_shipping_price = $shipping;
             }
             if ($shipping <= $min_shipping_price) {
                 $carrier_id = (int) $row->carrier_id;
                 $min_shipping_price = $shipping;
             }
         }
     }
     if (empty($carrier_id)) {
         $carrier_id = JeproshopSettingModelSeting::getValue('default_carrier');
     }
     if (!isset(self::$_carriers[$carrier_id])) {
         self::$_carriers[$carrier_id] = new JeproshopCarrierModelCarrier((int) $carrier_id, JeproshopSettingModelSeting::getValue('default_lang'));
     }
     $carrier = self::$_carriers[$carrier_id];
     // No valid Carrier or $carrier_id <= 0 ?
     if (!JeproshopValidator::isLoadedObject($carrier, 'carrier_id')) {
         JeproshopCache::store($cache_id, 0);
         return 0;
     }
     if (!$carrier->published) {
         JeproshopCache::store($cache_id, $shipping_cost);
         return $shipping_cost;
     }
     // Free fees if free carrier
     if ($carrier->is_free == 1) {
         JeproshopCache::store($cache_id, 0);
         return 0;
     }
     // Select carrier tax
     if ($use_tax && !JeproshopTaxModelTax::excludedTaxOption()) {
         $address = JeproshopAddressModelAddress::initialize((int) $address_id);
         $carrier_tax = $carrier->getTaxesRate($address);
     }
     $configuration = JeproshopSettingModelSeting::getValueMultiple(array('PS_SHIPPING_FREE_PRICE', 'PS_SHIPPING_HANDLING', 'PS_SHIPPING_METHOD', 'PS_SHIPPING_FREE_WEIGHT'));
     // Free fees
     $free_fees_price = 0;
     if (isset($configuration['PS_SHIPPING_FREE_PRICE'])) {
         $free_fees_price = JeproshopValidator::convertPrice((double) $configuration['PS_SHIPPING_FREE_PRICE'], JeproshopCurrencyModelCurrency::getCurrencyInstance((int) $this->currency_id));
     }
     $orderTotalWithDiscounts = $this->getOrderTotal(true, JeproshopCartModelCart::BOTH_WITHOUT_SHIPPING, null, null, false);
     if ($orderTotalWithDiscounts >= (double) $free_fees_price && (double) $free_fees_price > 0) {
         Cache::store($cache_id, $shipping_cost);
         return $shipping_cost;
     }
     if (isset($configuration['PS_SHIPPING_FREE_WEIGHT']) && $this->getTotalWeight() >= (double) $configuration['PS_SHIPPING_FREE_WEIGHT'] && (double) $configuration['PS_SHIPPING_FREE_WEIGHT'] > 0) {
         JeproshopCache::store($cache_id, $shipping_cost);
         return $shipping_cost;
     }
     // Get shipping cost using correct method
     if ($carrier->range_behavior) {
         if (!isset($zone_id)) {
             // Get id zone
             if (isset($this->address_delivery_id) && $this->address_delivery_id && JeproshopCustomerModelCustomer::customerHasAddress($this->customer_id, $this->address_delivery_id)) {
                 $zone_id = JeproshopAddressModelAddress::getZoneIdByAddressId((int) $this->address_delivery_id);
             } else {
                 $zone_id = (int) $default_country->zone_id;
             }
         }
         if ($carrier->getShippingMethod() == JeproshopCarrierModelCarrier::WEIGHT_SHIPPING_METHOD && !JeproshopCarrierModelCarrier::checkDeliveryPriceByWeight($carrier->id, $this->getTotalWeight(), (int) $zone_id) || $carrier->getShippingMethod() == JeproshopCarrierModelCarrier::PRICE_SHIPPING_METHOD && !JeproshopCarrierModelCarrier::checkDeliveryPriceByPrice($carrier->id, $total_package_without_shipping_tax_inc, $zone_id, (int) $this->currency_id)) {
             $shipping_cost += 0;
         } else {
             if ($carrier->getShippingMethod() == Carrier::SHIPPING_METHOD_WEIGHT) {
                 $shipping_cost += $carrier->getDeliveryPriceByWeight($this->getTotalWeight($product_list), $zone_id);
             } else {
                 // by price
                 $shipping_cost += $carrier->getDeliveryPriceByPrice($order_total, $zone_id, (int) $this->currency_id);
             }
         }
     } else {
         if ($carrier->getShippingMethod() == JeproshopCarrierModelCarrier::WEIGHT_SHIPPING_METHOD) {
             $shipping_cost += $carrier->getDeliveryPriceByWeight($this->getTotalWeight($product_list), $zone_id);
         } else {
             $shipping_cost += $carrier->getDeliveryPriceByPrice($order_total, $zone_id, (int) $this->currency_id);
         }
     }
     // Adding handling charges
     if (isset($configuration['PS_SHIPPING_HANDLING']) && $carrier->shipping_handling) {
         $shipping_cost += (double) $configuration['PS_SHIPPING_HANDLING'];
     }
     // Additional Shipping Cost per product
     foreach ($products as $product) {
         if (!$product->is_virtual) {
             $shipping_cost += $product->additional_shipping_cost * $product->cart_quantity;
         }
     }
     $shipping_cost = JeproshopValidator::convertPrice($shipping_cost, JeproshopCurrencyModelCurrency::getCurrencyInstance((int) $this->currency_id));
     /*/get external shipping cost from module
             if ($carrier->shipping_external)
             {
                 $module_name = $carrier->external_module_name;
                 $module = Module::getInstanceByName($module_name);
     
                 if (JeproshopValidator::isLoadedObject($module))
                 {
                     if (array_key_exists('carrier_id', $module))
                         $module->carrier_id = $carrier->id;
                     if ($carrier->need_range)
                         if (method_exists($module, 'getPackageShippingCost'))
                             $shipping_cost = $module->getPackageShippingCost($this, $shipping_cost, $products);
                         else
                             $shipping_cost = $module->getOrderShippingCost($this, $shipping_cost);
                     else
                         $shipping_cost = $module->getOrderShippingCostExternal($this);
     
                     // Check if carrier is available
                     if ($shipping_cost === false)
                     {
                         JeproshopCache::store($cache_id, false);
                         return false;
                     }
                 }
                 else
                 {
                     JeproshopCache::store($cache_id, false);
                     return false;
                 }
             } */
     // Apply tax
     if ($use_tax && isset($carrier_tax)) {
         $shipping_cost *= 1 + $carrier_tax / 100;
     }
     $shipping_cost = (double) JeproshopValidator::roundPrice((double) $shipping_cost, 2);
     JeproshopCache::store($cache_id, $shipping_cost);
     return $shipping_cost;
 }
Example #4
0
checked="checked"<?php 
    }
    ?>
 />
                        <label for="gift">
                            <?php 
    echo JText::_('COM_JEPROSHOP_I_WOULD_LIKE_MY_ORDER_TO_BE_GIFT_WRAPPED_LABEL');
    if ($this->gift_wrapping_price > 0) {
        echo '&nbsp;<i>(' . JText::_('COM_JEPROSHOP_ADDITIONAL_COST_OF_LABEL');
        ?>
                            <span class="price" id="jform_gift_price" >
                                <?php 
        if ($this->display_price == 1) {
            echo JeproshopValidator::convertPrice($total_wrapping_tax_exc_cost);
        } else {
            echo JeproshopValidator::convertPrice($total_wrapping_cost);
        }
        ?>
				            </span>
                                <?php 
        if ($this->use_taxes && $this->display_tax_label) {
            if ($this->display_price == 1) {
                echo JText::_('COM_JEPROSHOP_TAX_EXCLUDED_LABEL') . ')';
            } else {
                echo JText::_('COM_JEPROSHOP_TAX_INCLUDED_LABEL') . ')';
            }
        }
        echo ')</i> ';
    }
    ?>
                        </label>