magento получит экономию на вашей корзине - PullRequest
0 голосов
/ 27 января 2012

Я гуглил как сумасшедший здесь .. Я хочу простую вещь.Получите разницу общей стоимости всех продуктов по обычной цене от общей специальной / проверенной / скорректированной цены всех продуктов в корзине.

IE: если в корзине было 2 товара,имеют нормальный ценовой атрибут, такой как

1 @ $5
2 @ $10
--------------------------
total = $15 Savings = $0

, но затем я делаю специальную цену для # 2, поэтому корзина будет

1 @ $5
2 @ $5
--------------------------
total = $10 Savings = $5

Теперь я знаю, что могу использовать

$this->helper('checkout')->formatPrice(Mage::getSingleton('checkout/cart')->getQuote()->getGrandTotal()); 

Чтобы получить общий итог, но я не на 100%, что не без доставки ... но это было бы с применением специальной цены.Мне тоже понадобятся общие нормальные затраты, тогда я смогу сделать простую математику.

Что я хочу сделать, это поместить их в числа в заголовке и на боковой панели ... Идеи?

1 Ответ

0 голосов
/ 29 января 2012

на странице просмотра товара

<?php 
   $_product = $this->getProduct(); ?>  

   if ($_product->getTypeId() == 'bundle'){
      list($_minimalPrice, $_maximalPrice) = $_product->getPriceModel()->getPrices($_product);
      $this->_price = $_minimalPrice;
      $this->_specialPrice = $_minimalPrice;
      if (!is_null($_product->getData('special_price')) && ($_product->getData('special_price') < 100)){  
         $this->_regularPrice = ($this->_specialPrice / $_product->getData('special_price')) * 100;  
      } else {
         $this->_regularPrice = $this->_specialPrice;
      }
    } else {
       $this->_price = 0;
       $this->_regularPrice = $_product->getPrice();
       $this->_specialPrice = $_product->getFinalPrice();
    }
    if ( $this->_specialPrice != $this->_regularPrice )
    {
       if ($this->_regularPrice > 0)
       {
          $this->_discountAmount = round( ( 1 - $this->_specialPrice / $this->_regularPrice ) * 100 );
          $this->_saveAmount = $this->_regularPrice - $this->_specialPrice;
       }
     }

    if ($this->_regularPrice)
    {
        $this->_regularPrice = strip_tags( Mage::app()->getStore()->convertPrice( $this->_regularPrice, true ) );
    }
    if ($this->_specialPrice)
    {
        $this->_specialPrice = strip_tags( Mage::app()->getStore()->convertPrice( $this->_specialPrice, true ) );
    }
    if ($this->_saveAmount)
    {
        $this->_saveAmount   = strip_tags( Mage::app()->getStore()->convertPrice( $this->_saveAmount, true )   );
    }
    if ($this->_discountAmount)
    {
        $this->_discountAmount = $this->_discountAmount . '%';
    }

Итак, есть _saveAmount и _discountAmount, используйте в своем шаблоне, но я не проверял его, будьте осторожны на рабочей площадке.

...