X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   General questions (X-Cart 5) (https://forum.x-cart.com/forumdisplay.php?f=66)
-   -   Shipping Cost (https://forum.x-cart.com/showthread.php?t=75994)

gzervas1976 02-16-2018 05:46 AM

Shipping Cost
 
Hello,

is it possible to get the shipping cost of an order in the #checkoutSuccess# ?

I get the total cost like this {{ this.order.getOrderNumber() }} how I can get the shipping cost?

Thank you

I use the X-Cart Business 5.3.4.5

qualiteam 02-19-2018 07:38 AM

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.


All times are GMT -8. The time now is 11:56 AM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.