/**
  * Set response in special format
  *
  * @param Varien_Object $response
  * @return Sitemaster_Checkout_CheckoutController
  */
 protected function _respondWith(Varien_Object $response)
 {
     if ($response->hasErrorMessage()) {
         $errorHtml = $this->getLayout()->createBlock('core/messages')->addError($response->getErrorMessage())->getGroupedHtml();
         $response->setErrorMessage($errorHtml);
     }
     $this->getResponse()->setBody($response->toJson());
     return $this;
 }
Example #2
0
 /**
  * Get shipping rate code title and its price or error message
  *
  * @param Varien_Object $rate
  * @param string $format
  * @param string $inclTaxFormat
  * @return string
  */
 public function renderShippingRateOption($rate, $format = '%s - %s%s', $inclTaxFormat = ' (%s %s)')
 {
     $renderedInclTax = '';
     if ($rate->getErrorMessage()) {
         $price = $rate->getErrorMessage();
     } else {
         $price = $this->_getShippingPrice($rate->getPrice(), $this->helper('tax')->displayShippingPriceIncludingTax());
         $incl = $this->_getShippingPrice($rate->getPrice(), true);
         if ($incl != $price && $this->helper('tax')->displayShippingBothPrices()) {
             $renderedInclTax = sprintf($inclTaxFormat, Mage::helper('tax')->__('Incl. Tax'), $incl);
         }
     }
     return sprintf($format, $this->escapeHtml($rate->getMethodTitle()), $price, $renderedInclTax);
 }
Example #3
0
 /**
  * Gets the title of the delivery method
  * with or without delivery
  *
  * @param Varien_Object $method
  * @param bool $includeDeliveryTime
  * @return string
  */
 protected function _getMethodTitle(Varien_Object $method, $includeDeliveryTime = false)
 {
     $title = $this->_getHelper()->getMethodTitle($method->getCode());
     if ($method->getShowMessage() && $method->hasErrorMessage()) {
         $title .= sprintf(' - %s', $method->getErrorMessage());
     }
     if ($includeDeliveryTime) {
         if ($method->getDeliveryTime() > 1) {
             return $this->_getHelper()->__('%s (%d working days)', $title, $method->getDeliveryTime());
         } else {
             return $this->_getHelper()->__('%s (%d working day)', $title, $method->getDeliveryTime());
         }
     }
     return $title;
 }