예제 #1
0
 /**
  * Returns a product price in the active currency, depending on the
  * Customer and special offer status.
  * @param   Customer  $objCustomer      The Customer, or null
  * @param   double    $price_options    The price for Attributes,
  *                                      if any, or 0 (zero)
  * @param   integer   $count            The number of products, defaults
  *                                      to 1 (one)
  * @param   boolean   $ignore_special_offer
  *                                      If true, special offers are ignored.
  *                                      This is needed to actually determine
  *                                      both prices in the products view.
  *                                      Defaults to false.
  * @return  double                      The price converted to the active
  *                                      currency
  * @author    Reto Kohli <*****@*****.**>
  */
 function get_custom_price($objCustomer = null, $price_options = 0, $count = 1, $ignore_special_offer = false)
 {
     $normalPrice = $this->price();
     $resellerPrice = $this->resellerprice();
     $discountPrice = $this->discountprice();
     $discount_active = $this->discount_active();
     $groupCountId = $this->group_id();
     $groupArticleId = $this->article_id();
     $price = $normalPrice;
     if (!$ignore_special_offer && $discount_active == 1 && $discountPrice != 0) {
         $price = $discountPrice;
     } else {
         if ($objCustomer && $objCustomer->is_reseller() && $resellerPrice != 0) {
             $price = $resellerPrice;
         }
     }
     $price += $price_options;
     $rateCustomer = 0;
     if ($objCustomer) {
         $groupCustomerId = $objCustomer->group_id();
         if ($groupCustomerId) {
             $rateCustomer = Discount::getDiscountRateCustomer($groupCustomerId, $groupArticleId);
             $price -= $price * $rateCustomer * 0.01;
         }
     }
     $rateCount = 0;
     if ($count > 0) {
         $rateCount = Discount::getDiscountRateCount($groupCountId, $count);
         $price -= $price * $rateCount * 0.01;
     }
     $price = Currency::getCurrencyPrice($price);
     return $price;
 }
예제 #2
0
 /**
  * Set up the full set of discount information placeholders
  * @param   integer   $groupCustomerId    The customer group ID of the current customer
  * @param   integer   $groupArticleId     The article group ID of the current article
  * @param   integer   $groupCountId       The count discount group ID of the current article
  * @param   integer   $count              The number of articles to be used for the count discount
  * @static
  * @author    Reto Kohli <*****@*****.**>
  */
 static function showDiscountInfo($groupCustomerId, $groupArticleId, $groupCountId, $count)
 {
     // Pick the unit for this product (count, meter, kilo, ...)
     $unit = Discount::getUnit($groupCountId);
     if (!empty($unit)) {
         self::$objTemplate->setVariable('SHOP_PRODUCT_UNIT', $unit);
     }
     if ($groupCustomerId > 0) {
         $rateCustomer = Discount::getDiscountRateCustomer($groupCustomerId, $groupArticleId);
         if ($rateCustomer > 0) {
             self::$objTemplate->setVariable(array('SHOP_DISCOUNT_RATE_CUSTOMER' => $rateCustomer));
         }
     }
     if ($groupCountId > 0) {
         $rateCount = Discount::getDiscountRateCount($groupCountId, $count);
         $listCount = self::getDiscountCountString($groupCountId);
         if ($rateCount > 0) {
             // Show discount rate if applicable
             self::$objTemplate->setVariable('SHOP_DISCOUNT_RATE_COUNT', $rateCount);
         }
         if (!empty($listCount)) {
             // Show discount rate string if applicable
             self::$objTemplate->setVariable('SHOP_DISCOUNT_RATE_COUNT_LIST', $listCount);
         }
     }
 }