简体   繁体   中英

Prestashop shipping cost depending of country

I'm working on upgrading my e-shop on Prestashop. I want to edit shipping (carrier) cost depending of what country this will be sent. In theory I want to put price for delivery = 1 in backoffice and then in code edit this depending of country/weight or other options.

I think I find out function which get shipping price. This is getTotalShippingCost or this is getOrderTotal Please, tell if I'm wrong.

How can I get country name for delivery in getOrderTotal at this point?

if ($type == Cart::ONLY_SHIPPING)
return $shipping_fees;

Or if at this point of order no address can't be get, please tell where this doing. In ParentOrderController.php or in PaymentModule.php or somewhere else?

How to manage shipping/carriers you can read in Prestashop documentation , and to get shipping price per country (by default Presta use 'zones') without using external modules, you can create zone for each country and set shipping cost for each of these new zones. All these operations can be done from backoffice, without core changes.

But if you do decide to do it in the code, just keep in mind that it's considered bad practise to change core files directly; it is better way use built-in capabilities .

$shippingCostTaxExc can be found in _assignSummaryInformations method in /controllers/front/ParentOrderController.php file. 

$option array in /classes/Cart.php

Update: You can get access to some common objects like Currency, Cookie etc. and Country too from any model/controllers classes, using Context object , so in your case, if you need Country name, it will looks like this:

$context = Context::getContext();
$context->country->name[1]; // for language with id=1
$context->language->id; // if you need to get actual customer language

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM