phpjoomlavirtuemart

How to get shipment amount in VirtueMart


I need to receive the goods sum including the delivery cost.

How can I do that?

I receive the order of

$order_info = $order_model->getOrder($order_id);
foreach ($order_info['items'] as $item) {   ...$item['amount']; // it's amount }

Solution

  • Could you get your question more concret? like why you want to get shipment amount? and what exactly shipment amount you want? amount with tax and amount has convert by different currency rate?

    If you need to find some object shipment amount from virtuemart, you could find in this file: plugins/vmshipment/weight_countries/weight_countries.php ( if you use weight_countries plugin to calcule the shipment)

    /**
         * @param VirtueMartCart $cart
         * @param                $method
         * @param                $cart_prices
         * @return int
         */
        function getCosts (VirtueMartCart $cart, $method, $cart_prices) {
    
            if ($method->free_shipment && $cart_prices['salesPrice'] >= $method->free_shipment) {
                return 0.0;
            } else {
                return $method->shipment_cost + $method->package_fee;
            }
        }
    

    But be careful to change the shipment_cost object it has related lots different class inherit, if you want to change the amount calculation I would suggestion use this plugin instead: https://extensions.joomla.org/extension/advanced-shipping-by-rules-for-virtuemart/