Thread: Shipping Cost
View Single Post
  #2  
Old 02-19-2018, 07:38 AM
  qualiteam's Avatar 
qualiteam qualiteam is offline
 

X-Guru
  
Join Date: Dec 2010
Posts: 6,373
 

Default Re: Shipping Cost

The shipping cost is just an extra sum stored for the order along with other sums like taxes, handling fees and so on. For each such a sum there is a database row, but there is no ready-made method that would distinct between the rows and return the shipping cost only.

However, it is possible to get the shipping cost from a custom module. Here is the code that the PayPal module uses to pass that value to PayPal servers:
PHP Code:
protected function getShippingCost($order)
    {
        
$result null;

        
$shippingModifier $order->getModifier(\XLite\Model\Base\Surcharge::TYPE_SHIPPING'SHIPPING');

        if (
$shippingModifier && $shippingModifier->canApply()) {
            
/** @var \XLite\Model\Currency $currency */
            
$currency $order->getCurrency();

            
$result $currency->roundValue(
                
$order->getSurchargeSumByType(\XLite\Model\Base\Surcharge::TYPE_SHIPPING)
            );
        }

        return 
$result;
    } 

So, first of all you should find what widget class provides methods to the template where you want the shipping cost to be displayed.
Then you "decorate" that class from your custom module, add the above method and call this method from your custom template.
__________________
Alex Solovev,
Qualiteam

---

User manual Video tutorials X-Cart FAQ

You are welcome to press "Thanks" button
if you find this post useful

Click here to learn how to apply patches

X-Cart Extensions
Reply With Quote