Search code examples
prestashopprestashop-1.7

Country Selector for Shipping Estimation


I am using PS 1.7.6.4. I would like guest shoppers to be able to select their country to get an accurate estimate of their shipping cost. I have put the following code in the /themes/classic/templates/_partials/header.tpl file:

{assign var='countries' value=Carrier::getDeliveredCountries(1, true, true)}
<select class="form-control-select js-country" name="id_country">
    {foreach from=$countries item=v}
    <option value="{$v.id_country}">{$v.name|escape:'html':'UTF-8'}</option>
    {/foreach}
</select>

How do I pass the selection to the cart for shipping calculation?


Solution

  • If you don’t want build your own module and just put the select inside header you have two options:

    1. When user choose one options put it to cookie file and read in cart

    OR

    1. Use browser local storage.

    Anyway - Inside Cart you have to make an Ajax Request to get info from database OR store your info in Json inside body of cart.

    Both will work locally only in user browser, but it’s only estimated.