PrestaShop / PrestaShop

PrestaShop is the universal open-source software platform to build your e-commerce solution.
https://www.prestashop-project.org/
Other
8.23k stars 4.81k forks source link

Shipping cost not needed needed to show to client if this don't select a shipping method yet #29082

Open TecnoHands opened 2 years ago

TecnoHands commented 2 years ago

Prerequisites

Describe the bug and add screenshots

Shipping cost always viewing, in modal and the cart before the buyer select a shipping method... image

Expected behavior

Shipping cost in a "normal" instance don't needed to show to client if this don't select a shipping method yet

Steps to reproduce

  1. install clean prestashop
  2. Add an article to the cart in quickview
  3. module ps_shoppingcart and cart summary etc show shipping cost but you don't select a shipping method yet

PrestaShop version(s) where the bug happened

1.7.*

PHP version(s) where the bug happened

1.7.4.3

If your bug is related to a module, specify its name and its version

ps_shoppingcart & Classic theme version 1.0.0

TecnoHands commented 2 years ago

### This changes in the tpls resolve the problem Please add it to the new release

Change the ps_shoppingcart -> modal.tpl Deleting or commenting this lines:

{if $cart.subtotals.shipping.value}
                <p><span>{l s='Shipping:' d='Shop.Theme.Checkout'}</span>&nbsp;<span class="shipping value">{$cart.subtotals.shipping.value} {hook h='displayCheckoutSubtotalDetails' subtotal=$cart.subtotals.shipping}</span></p>
              {/if}

in theme modify this two .tpl files:

cart-summary-subtotals.tpl -> add && $subtotal.type !== 'shipping' in the if line: 29

{**
 * Copyright since 2007 PrestaShop SA and Contributors
 * PrestaShop is an International Registered Trademark & Property of PrestaShop SA
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Academic Free License 3.0 (AFL-3.0)
 * that is bundled with this package in the file LICENSE.md.
 * It is also available through the world-wide-web at this URL:
 * https://opensource.org/licenses/AFL-3.0
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@prestashop.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade PrestaShop to newer
 * versions in the future. If you wish to customize PrestaShop for your
 * needs please refer to https://devdocs.prestashop.com/ for more information.
 *
 * @author    PrestaShop SA and Contributors <contact@prestashop.com>
 * @copyright Since 2007 PrestaShop SA and Contributors
 * @license   https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
 *}

<div class="card-block cart-summary-subtotals-container js-cart-summary-subtotals-container">

  {foreach from=$cart.subtotals item="subtotal"}
    {if $subtotal && $subtotal.value|count_characters > 0 && $subtotal.type !== 'tax' **_&& $subtotal.type !== 'shipping'_**}
      <div class="cart-summary-line cart-summary-subtotals" id="cart-subtotal-{$subtotal.type}">

        <span class="label">
            {$subtotal.label}
        </span>

        <span class="value">
          {if 'discount' == $subtotal.type}-&nbsp;{/if}{$subtotal.value}
        </span>
      </div>
    {/if}
  {/foreach}

</div>

modify cart-detailed-totals.tpl -> add && $subtotal.type !== 'shipping' in the if line: 21

 * https://opensource.org/licenses/AFL-3.0
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@prestashop.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade PrestaShop to newer
 * versions in the future. If you wish to customize PrestaShop for your
 * needs please refer to https://devdocs.prestashop.com/ for more information.
 *
 * @author    PrestaShop SA and Contributors <contact@prestashop.com>
 * @copyright Since 2007 PrestaShop SA and Contributors
 * @license   https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
 *}
{block name='cart_detailed_totals'}
<div class="cart-detailed-totals js-cart-detailed-totals">

  <div class="card-block cart-detailed-subtotals js-cart-detailed-subtotals">
    {foreach from=$cart.subtotals item="subtotal"}
      {if $subtotal && $subtotal.value|count_characters > 0 && **_$subtotal.type !== 'tax' && $subtotal.type !== 'shipping'_**}
        <div class="cart-summary-line" id="cart-subtotal-{$subtotal.type}">
          <span class="label{if 'products' === $subtotal.type} js-subtotal{/if}">
            {if 'products' == $subtotal.type}
              {$cart.summary_string}
            {else}
              {$subtotal.label}
            {/if}
          </span>
          <span class="value">
            {if 'discount' == $subtotal.type}-&nbsp;{/if}{$subtotal.value}
          </span>
          {if $subtotal.type === 'shipping'}
              <div><small class="value">{hook h='displayCheckoutSubtotalDetails' subtotal=$subtotal}</small></div>
          {/if}
        </div>
      {/if}
    {/foreach}
  </div>

  {block name='cart_summary_totals'}
    {include file='checkout/_partials/cart-summary-totals.tpl' cart=$cart}
  {/block}

  {block name='cart_voucher'}
    {include file='checkout/_partials/cart-voucher.tpl'}
  {/block}
</div>
{/block}
matks commented 2 years ago

This changes in the tpls resolve the problem Please add it to the new release

You can do it by submitting a Pull Request to ps_shoppingcart 😉 https://github.com/prestashop/ps_shoppingcart

AureRita commented 2 years ago

Hi @TecnoHands ,

Thank you for your reporting. Currently, I think you send a feature that you want into prestashop, so I'll treat it as if it were one.

The Product Team will take it into consideration for future developments.

Please be aware that there is no guarantee that this feature will be developed anytime soon. Thanks for your purposed modification :rocket:

Thank you

TecnoHands commented 2 years ago

I give you a solution, where You see a online store shows shipping cost before You select one? 🤦 In My opinion that is a Bad Workflow. I begin to think the proyect leaves this type of event without corrections with that intention appears how PrestaShop are "Open source" but not completely really

TecnoHands commented 2 years ago

I don't how 😔

ghost commented 2 years ago

Hello @TecnoHands

Anyone can make changes to improve the project. That's also what open source is.

If you need help i can help you. It is important to know that PrestaShop is international and that some countries ask for the shipping price when adding to the cart.

matks commented 2 years ago

I begin to think the proyect leaves this type of event without corrections with that intention appears how PrestaShop are "Open source" but not completely really

Please try to contribute to a positive environment, and focus on what is best for the community and show empathy towards other members rather than just say we have bad intentions.

Hlavtox commented 2 years ago

After your change, it will show Subtotal 114 and Total 118. What are the 4 dollars for when you hide the shipping?

You need to think about this more. ;-) Then we can implement something like this. The idea is good, but it must be configurable. Some clients want the original behavior, to preview the shipping cost to customer.

TecnoHands commented 2 years ago

After your change, it will show Subtotal 114 and Total 118. What are the 4 dollars for when you hide the shipping?

You need to think about this more. ;-) Then we can implement something like this. The idea is good, but it must be configurable. Some clients want the original behavior, to preview the shipping cost to customer.

The idea is show shipping cost when client select one shipping method if you don't selected any shipping method why you show a shipping cost.

I see a error in my solution and I try to solve it but I can't find the documentation about the $subtotal var to go more deeper :(

Thanks for the feedback

Hlavtox commented 2 years ago

@TecnoHands You must check another variable. Put this to your template and you will see all the totals available. 🙂

{dump($cart.totals)}

alisamie97 commented 2 years ago

@TecnoHands As far as I know, in prestashop checkout there are two main steps.

These steps are pretty good designed to be modular. And they use current active address to show the best AVAILABLE options both for delivery and payment. So when you add an item to the cart, it checks your current active delivery address to find best suited delivery option based on the sorting you have set in BO and also available payment options. The thing is, if there is no shipping selected, you can not see the cart total because the equation is incomplete, you are only able to see the subtotal of cart items.

TecnoHands commented 2 years ago

@TecnoHands As far as I know, in prestashop checkout there are two main steps.

  • shipping
  • payment

These steps are pretty good designed to be modular. And they use current active address to show the best AVAILABLE options both for delivery and payment. So when you add an item to the cart, it checks your current active delivery address to find best suited delivery option based on the sorting you have set in BO and also available payment options. The thing is, if there is no shipping selected, you can not see the cart total because the equation is incomplete, you are only able to see the subtotal of cart items.

Very thanks for the explanation