Prestashop: Free shipping as visitor

Created on 27 Sep 2018  Â·  32Comments  Â·  Source: PrestaShop/PrestaShop

Describe the bug
Hello, I've noticed a bug with displaying shipping cost in the cart. As the guest there is always free shipping. As logged member shipping cost is displaying correctly.

I have only one Carrier (DHL). Shipping costs are calculating by summary package weight and there is no free shipping option.

I've run out of ideas. Can You help me with this issue?

To Reproduce
Steps to reproduce the behavior:

  1. Go to ' https://www.febe.store/shop/de/ '
  2. Click on ' every product and add it to cart as visitor '
  3. See shipping cost at cart

Screenshots
In attachment 2 screenshots:

  • in first there is item added as visitor - there are no shipping cost
  • second - same item as above but while logged in customer account. Shipping cost are calculated correctly

Additionnal information
PrestaShop version: 1.7.4.2
PHP version: 5.6.32

member
visitor

1.7.4.2 1.7.5.1 1.7.6.0 Bug Carriers FO Fixed Minor PR available Shipping preferences Topwatchers

Most helpful comment

OK just did. I hope it's OK it's my first one :)

All 32 comments

Hi @febestore,

In the BO => IMPROVE => Shipping => Preferences => you need to edit the Default carrier.
Thanks to check & feedback.

Best regards, Khouloud

The default carrier was set up before. The problem still exists.
Screenshot below

d-shipp

Hi @febestore,

I attached a video record.
https://drive.google.com/file/d/1WCGGfFAmE5Yt_HwgivnYcti1cznYmnZP/view
Thanks to check & feedback.

Best regards, Khouloud

Hi @febestore,

Have you tried to contact the theme author about this issue?
Thanks to check with them & feedback.

Best regards, Khouloud

Hi,
Yes I did. They replied:
"Sorry, I don't know this issue.
I think you should contact to PrestaShop for this issue."

So none knows how to fix this?

@febestore, it could be a multistore issue.
Could you please try to disable the multistore context, check & feedback.
Thanks!

Hey,
I can't do this. I have too many external connections with all shops. I need to keep multistore on.
Anyway if it's a multistore issue it should be fixed anyway, doesn't it?

Hi @febestore,

I'm not sure that the problem is a multistore issue.
Because in my local, I did not manage to reproduce the issue with multistore context enabled / multistore context disabled.
Could you please provide me the credentials of your shop Backend to test it.
This is a public space.
You can provide me the module by email.
My address mail: khouloud.[email protected]
Let's be safe!

Thanks!

That's great. I'm sending You mail :)

Hi @febestore,

I attached a video record.
https://drive.google.com/file/d/1SzeSJVLInkARlr08WGjU44f2P16hakAH/view
Thanks to check & feedback.

Yes, default carrier is set, but adding when You add a product to the shopping cart there is information about free shipping - that's what I want to get rid off.
Is there a solution?

Hi @febestore,

Thanks for this clarifications.
I manage to reproduce the issue with the last version 1.7.4.3.
Steps to reproduce the issue:
1- there are no carriers in the shop
image
2- Navigate to FO
3- Add some products to the cart => process to checkout
4- In the third step: an alert is displayed"Unfortunately, there are no carriers available for your delivery address." but in the cart summary: The shipping label is displayed with free value.
image

Thanks!

Hi, all carriers are set. The thing is - its available after You write address and zip-code.
Is it possible to make default carrier to be displayed all the time?

I'm sending You new email with recording

Hi @febestore,

This issue should be fixed in this ticket: #9688
Thanks!

Hi,
I don't understand how it should fix my issue?
Can You be more specific? What should I do?

Thanks

Hi @febestore,

The issue #9688 is not fixed yet.
It should be specified by our developers, the problem IS that the Default carrier not really set in FO.
Thanks!

I am looking into it and I realize that the function : getDefaultCarrierSelection from /classes/carrier.php is defined but not used. Before the login of the customer (means, no adresses filled), this function should be used.
Today, by default, I don't know yet why, either no carrier is selected (free shipping) or another is used (no chance today it was Chronopost at 16€...).
I entered in this behavior after the installation of the new Colissimo (Collissimo - Officiel) module. Before, I guess by chance, the treatements were selecting the carrier I wanted.

Open the file /themes/xxx/modules/blockcart/blockcart.tpl
and remove this block of code (or comment):

<div class="layer_cart_row">
    <strong class="dark">
        {l s='Total shipping' mod='blockcart'}&nbsp;{if $display_tax_label}{if $priceDisplay == 1}{l s='(tax excl.)' mod='blockcart'}{else}{l s='(tax incl.)' mod='blockcart'}{/if}{/if}
    </strong>
    <span class="ajax_cart_shipping_cost">
        {if $shipping_cost_float == 0}
            {l s='Free shipping!' mod='blockcart'}
        {else}
            {$shipping_cost}
        {/if}
    </span>
</div>

@fredec This is not a solution. I do not have such file in module that is used by my client.

I could not find a solution. The only way I found was removing this piece of code.

1- there are no carriers in the shop

@khouloudbelguith, there is another situation: There IS a carrier, but it is from a module that needs a Zip Code to determine the order shipping cost.
The module will return "false" on getOrderShippingCost if no zip code is provided, so "Free!" will be shown in the cart.

Hi, I'm using Prestashop 1.7.5.1 with PHP 7.2 and have this issue. It's a problem because if you are not logged in or need postal codes to determine shipping, you always see shipping as "Free" in your cart, which really means "not calculated yet". It is bad for customer psychology to see "Free" and after they enter more information to get a price.

I managed to solve this by editing the file "srcAdapterPresenterCartCartPresenter.php". The result of this change is if there is shipping calculated then it will simply show it. If the system cannot determine shipping yet for any reason then you get "Not Calculated". Finally, if you really have free shipping then you get the indication "Free".

For my shop this works fine, please test it before copying this on a live shop.

  1. Add the following private function in "srcAdapterPresenterCartCartPresenter.php".

`````
private function getShippingDisplayValue($cart, $shippingCost)
{
$hasFreeCarrier = 0;
$default_country = null;

    if (isset(Context::getContext()->cookie->id_country)) {
        $default_country = new Country(Context::getContext()->cookie->id_country);
    }

    $delivery_option_list = $cart->getDeliveryOptionList($default_country);

    if (isset($delivery_option_list) && count($delivery_option_list) > 0) {                
        foreach ($delivery_option_list as $option) {
            foreach ($option as $currentCarrier) {                    
                if (isset($currentCarrier['is_free']) && $currentCarrier['is_free'] > 0) {                                                   
                    $hasFreeCarrier = 1;
                    break 2;                                                                        
                }                                                                  
            }
        }
    }

    $shippingDisplayValue = '';

    if ($shippingCost != 0) {
        $shippingDisplayValue = $this->priceFormatter->format($shippingCost);
    } elseif ($hasFreeCarrier == 0) {
        $shippingDisplayValue = $this->translator->trans('Not Calculated', array(), 'Shop.Theme.Checkout');
    } else {
        $shippingDisplayValue = $this->translator->trans('Free', array(), 'Shop.Theme.Checkout');
    }

    return $shippingDisplayValue;
}

`````

  1. Call the above function in same file at line 370 (in function "present") to get 'value' in subtotals.
    Replace this:
'value' => $shippingCost != 0
                ? $this->priceFormatter->format($shippingCost)
                : $this->translator->trans('Free', array(), 'Shop.Theme.Checkout'),

with this:

'value' => $this->getShippingDisplayValue($cart, $shippingCost),

The next issue that is related to another Prestashop bug is that you won't be able to translate "Not Calculated" from back-office. In order to translate you have to manually (E.g. through PHPMyAdmin) insert two rows in 'ps_translation' table. For my case I have English (id = 1) and Greek (id = 2), so these are my statements:

INSERT INTO `ps_translation`(`id_lang`, `key`, `translation`, `domain`, `theme`) VALUES (1,'Not Calculated','Not Calculated','ShopThemeCheckout','classic');

INSERT INTO `ps_translation`(`id_lang`, `key`, `translation`, `domain`, `theme`) VALUES (2,'Not Calculated','Δεν υπολογίστηκε','ShopThemeCheckout','classic');

Hi @hacchus,

Would you be willing to make a pull request on GitHub with your code suggestion?
https://github.com/PrestaShop/PrestaShop/tree/develop
Thank you!

OK just did. I hope it's OK it's my first one :)

@khouloudbelguith I have the same issue with #1752 version. I develop a checkout module (locally obviously) and I thought it may be related to my code.

As a result, I made a vanilla PrestaShop, edited the carrier costs (not free, send all over the world) and still shipping is 0.

@hacchus I am greek too (I just write in English due to the respect we ought to the community). If you like to get in contact, send me a message on [email protected]

@khouloudbelguith The issue seems fixed.
I tried the @hacchus solution. Not working. I reverted the code.
Works (when the same code wasn't working).

Check with your colleagues if there is some cache issue on this bug.

@khouloudbelguith Could you try to reproduce this issue with 1752 & 176x branch ?

Hi @marionf,

Yes, as described in this comment: https://github.com/PrestaShop/PrestaShop/issues/10739#issuecomment-430632240
I manage to reproduce the issue with Branch 176x, PS1760beta1 & PS1752(machine shuffle).
https://drive.google.com/file/d/12kDhSsN_oNbVy0LxdshPUcIEnHU28zYz/view
I cleared the cache from PrestaShop & from the browser => same issue.
Thanks!

The answer is not complicated. The solution is here. https://prestashop.axvisualpromocom.com/blog/zonas-transportistas-prestashop-1-7/

Hi

I have see the replies and me i have on PS 1.7.5.1 a bug with DHL. Now i can select it for the delivery but it bugs with payments.
It works very well with others delivery like #colissimo #chronopost and the virtual tpe from
MONETIC CIC and cheq worlks well too. They said to me that after looking the BO and databse or shop delivery parameters with payment if have no possibility to pay with @DHLExpressFr does not work with the payments hat it comes from a bug of prestashop 1.7.5.1 is it correct? Did anyone had this bug with DHL and payments?

Best

Kolorslab

here some captures

https://www.kolorslab.com/dhl1.png
https://www.kolorslab.com/dh2.png
https://www.kolorslab.com/dhl3.png
https://www.kolorslab.com/dhl4.png

How can I set the translation of this not calculated text it doesn't show up in my translations section

Hi I tkink that I have a smiliar problem.

I have a diffrent carriers for diffrent countries.
When client is a visitor (not logged yet) and his localization is diffrent that default countrie set in shop, shipping cost in cart is free.
If client is a visitor (not logged yet) and his localization is the same as default countrie set in shop the shipping cost is correct.

I suppose that the geolocalization work correctly, but shop doesn't set shpping cost if default countrie is not the same as client's countrie localization.

Is the normal situation? How to repair this?

Another thing is that, when i try to disable Visitor's group for one of carrier than nothing happen. Still appear in cart.
But After this modification: https://github.com/PrestaShop/PrestaShop/pull/13517 it start work.
Why before that modification when I disabled visitor's group that function didn't work?

PrestaShop 1.7.6.1

Was this page helpful?
0 / 5 - 0 ratings