Skip to main content
Tiding formating
Source Link
nirleka
  • 3
  • 1
  • 4

Maybe global static code to only return shipping Order price (by passing tax calculation) since the requirement is outputting shipping price without tax.


Additional Detail:

--Magento version 1.7.0.2

Additional Detail:Here are Tax Configuration:

Magento version 1.7.0.2

  • Tax Class Shipping = None
  • Shipping price = Excluding tax
  • Display shipping price = Excuding Tax
  • Display shipping amount = Excluding tax
  • Include Tax in Grand Total, Full Tax Summary, Zero Tax Subtotal = No

I set Tax Class Shipping as NoneAfter tracing the code, shippingfunction Mage_Tax_Block_Checkout_Shipping::getShippingExcludeTax() is responsible for zero price excluding tax, and display shipping amount excluding tax in Tax Configuration(tested by return constant value that not zero).

After tracing the code, function Mage_Tax_Block_Checkout_Shipping::getShippingExcludeTax() returning zero. But, theThe shipping price in right side bar that returning right value is not zerousing Mage_Checkout_Block_Onepage_Progress::getShippingPriceExclTax() (tested by return constant value).

Here is the code of Mage_Tax_Block_Checkout_Shipping::getShippingExcludeTax()Here is the code of Mage_Tax_Block_Checkout_Shipping::getShippingExcludeTax()

class Mage_Tax_Block_Checkout_Shipping extends Mage_Checkout_Block_Total_Default
{
//... another code ...
    /**
     * Get shipping amount exclude tax
     *
     * @return float
     */
    public function getShippingExcludeTax()
    {
        //return zero
        //return 12345, front end shipping order review display 12345
        return $this->getTotal()->getAddress()->getShippingAmount();
    }
//... another code ...
}

Here is the code that not return zeroHere is the code that not return zero shipment price

class Mage_Checkout_Block_Onepage_Progress extends Mage_Checkout_Block_Onepage_Abstract
{
//... another code ...
    public function getShippingPriceExclTax()
    {
        //return 12345, right sidebar display 12345
        return $this->formatPrice($this->getQuote()->getShippingAddress()->getShippingAmount());
    }
//... another code ...
}

--

Additional Detail:

Magento version 1.7.0.2

I set Tax Class Shipping as None, shipping price excluding tax, and display shipping amount excluding tax in Tax Configuration.

After tracing the code, function Mage_Tax_Block_Checkout_Shipping::getShippingExcludeTax() returning zero. But, the shipping price in right side bar is not zero Mage_Checkout_Block_Onepage_Progress::getShippingPriceExclTax().

Here is the code of Mage_Tax_Block_Checkout_Shipping::getShippingExcludeTax()

class Mage_Tax_Block_Checkout_Shipping extends Mage_Checkout_Block_Total_Default
{
//... another code ...
    /**
     * Get shipping amount exclude tax
     *
     * @return float
     */
    public function getShippingExcludeTax()
    {
        //return zero
        return $this->getTotal()->getAddress()->getShippingAmount();
    }
//... another code ...
}

Here is the code that not return zero

class Mage_Checkout_Block_Onepage_Progress extends Mage_Checkout_Block_Onepage_Abstract
{
//... another code ...
    public function getShippingPriceExclTax()
    {
        return $this->formatPrice($this->getQuote()->getShippingAddress()->getShippingAmount());
    }
//... another code ...
}

Maybe global static code to only return shipping Order price (by passing tax calculation) since the requirement is outputting shipping price without tax.


Additional Detail:

Magento version 1.7.0.2

Here are Tax Configuration:

  • Tax Class Shipping = None
  • Shipping price = Excluding tax
  • Display shipping price = Excuding Tax
  • Display shipping amount = Excluding tax
  • Include Tax in Grand Total, Full Tax Summary, Zero Tax Subtotal = No

After tracing the code, function Mage_Tax_Block_Checkout_Shipping::getShippingExcludeTax() is responsible for zero price (tested by return constant value that not zero).

The shipping price in right side bar that returning right value is using Mage_Checkout_Block_Onepage_Progress::getShippingPriceExclTax() (tested by return constant value).

Here is the code of Mage_Tax_Block_Checkout_Shipping::getShippingExcludeTax()

class Mage_Tax_Block_Checkout_Shipping extends Mage_Checkout_Block_Total_Default
{
//... another code ...
    /**
     * Get shipping amount exclude tax
     *
     * @return float
     */
    public function getShippingExcludeTax()
    {
        //return zero
        //return 12345, front end shipping order review display 12345
        return $this->getTotal()->getAddress()->getShippingAmount();
    }
//... another code ...
}

Here is the code that not return zero shipment price

class Mage_Checkout_Block_Onepage_Progress extends Mage_Checkout_Block_Onepage_Abstract
{
//... another code ...
    public function getShippingPriceExclTax()
    {
        //return 12345, right sidebar display 12345
        return $this->formatPrice($this->getQuote()->getShippingAddress()->getShippingAmount());
    }
//... another code ...
}
add magento version
Source Link
nirleka
  • 3
  • 1
  • 4

Magento version 1.7.0.2

Magento version 1.7.0.2

Source Link
nirleka
  • 3
  • 1
  • 4

Shipping price in one page checkout - order review return zero

Greeting, i created custom shipping method and it working good. But, in one page checkout order review the shipping price is zero. Here is the picture of that: Zero shipping price

The shipping in the right sidebar is displaying correct value. How to make shipping value in Order Review not zero?

Any help or lead is highly appreciated. Thank you.

--

Additional Detail:

I set Tax Class Shipping as None, shipping price excluding tax, and display shipping amount excluding tax in Tax Configuration.

After tracing the code, function Mage_Tax_Block_Checkout_Shipping::getShippingExcludeTax() returning zero. But, the shipping price in right side bar is not zero Mage_Checkout_Block_Onepage_Progress::getShippingPriceExclTax().

Here is the code of Mage_Tax_Block_Checkout_Shipping::getShippingExcludeTax()

class Mage_Tax_Block_Checkout_Shipping extends Mage_Checkout_Block_Total_Default
{
//... another code ...
    /**
     * Get shipping amount exclude tax
     *
     * @return float
     */
    public function getShippingExcludeTax()
    {
        //return zero
        return $this->getTotal()->getAddress()->getShippingAmount();
    }
//... another code ...
}

Here is the code that not return zero

class Mage_Checkout_Block_Onepage_Progress extends Mage_Checkout_Block_Onepage_Abstract
{
//... another code ...
    public function getShippingPriceExclTax()
    {
        return $this->formatPrice($this->getQuote()->getShippingAddress()->getShippingAmount());
    }
//... another code ...
}

Basically, my custom shipping is fetching price from table of city name and price field. It use country_id, region_code, and city name from customer order to get price.

Here are the code of my custom shipping carrier

class Nirsoft_CityPrice_Model_Carrier extends Mage_Shipping_Model_Carrier_Abstract
                                               implements Mage_Shipping_Model_Carrier_Interface
{
    protected $_code = 'nirsoft_cityprice';
    private $destination_city;
    private $region;
    private $country;
    private $countryName;

    public function collectRates(Mage_Shipping_Model_Rate_Request $request)
    {
        $result = Mage::getModel('shipping/rate_result');
        /* @var $result Mage_Shipping_Model_Rate_Result */

        $this->destination_city = $request->getDestCity();
        $this->region = $request->getDestRegionId();
        $this->country = $request->getDestCountryId();
        $countryModel = Mage::getModel('directory/country')->loadByCode($this->country);
        $this->countryName = $countryModel->getName();

        $result->append($this->_calculateRate());
        if ($request->getFreeShipping()) {
            /**
             *  If the request has the free shipping flag,
             *  append a free shipping rate to the result.
             */
            $freeShippingRate = $this->_getFreeShippingRate();
            $result->append($freeShippingRate);
        }

        return $result;
    }

    protected function _calculateRate()
    {
        //get price from database
        $cityprice = Mage::getModel('nirsoft_cityprice/city')->getCollection();
        $cityprice->addFieldToFilter('country_id', array('eq' => $this->country))
                  ->addFieldToFilter('region_id', array('eq' => $this->region))
                  ->addFieldToFilter('name', array('eq' => ucwords($this->destination_city)));
        $city = $cityprice->getFirstItem();
        $price = $city->getPrice();

        if (!empty($price)) {
            if ($price > 0) {
                $rate = Mage::getModel('shipping/rate_result_method');
                /* @var $rate Mage_Shipping_Model_Rate_Result_Method */
                $rate->setCarrier($this->_code);
                $rate->setMethod('indonesia_shipping');

                if (Mage::app()->getLocale()->getLocaleCode() == 'ID' ) {
                    $rate->setCarrierTitle('Pengiriman '.$this->countryName);
                    $rate->setMethodTitle('Pengiriman '.$this->countryName);
                } else {
                    $rate->setCarrierTitle($this->countryName.' Shipping');
                    $rate->setMethodTitle($this->countryName.' Shipping');
                }

                $rate->setPrice($price);
                $rate->setCost(0);
                return $rate;
            } else {
                return $this->_getFreeShippingRate();
            }
        } else {
            return $this->_calculateRateNotListed();
        }
    }

    protected function _calculateRateNotListed()
    {
        $rate = Mage::getModel('shipping/rate_result_method');
        /* @var $rate Mage_Shipping_Model_Rate_Result_Method */
        $rate->setCarrier($this->_code);
        $rate->setMethod('indonesia_shipping');
        $rate->setCarrierTitle("Shipping Not Listed");

        if (Mage::app()->getLocale()->getLocaleCode() == 'ID' ) {
            $rate->setMethodTitle($this->getConfigData('message_checkout'));
        } else  {
            $rate->setMethodTitle($this->getConfigData('message_eng_checkout'));
        }

        // $rate->setPrice(0);
        return $rate;
    }

    protected function _getFreeShippingRate()
    {
        $rate = Mage::getModel('shipping/rate_result_method');
        /* @var $rate Mage_Shipping_Model_Rate_Result_Method */
        $rate->setCarrier($this->_code);
        $rate->setCarrierTitle(Mage::helper('nirsoft_cityprice')->__('Free Shipping'));
        $rate->setMethod('free_shipping');
        $rate->setMethodTitle(Mage::helper('nirsoft_cityprice')->__('Free Shipping for ').$this->destination_city);
        $rate->setPrice(0);
        $rate->setCost(0);
        return $rate;
    }


    public function getAllowedMethods()
    {
        if (Mage::app()->getLocale()->getLocaleCode() == 'ID' ) {
            $shipMethod = 'Pengiriman Indonesia';
        } else {
            $shipMethod = $this->countryName.' Shipping';
        }

        return array(
            'free_shipping' => 'Free Shipping',
            'indonesia_shipping' => $shipMethod
        );
    }

    public function isTrackingAvailable()
    {
        return true;
    }
}