Jump to content

Prestashop 1.7 - Cart Update in Payment Refreshes to Address


zackrocha14

Recommended Posts

I am creating a module to detect out of stock products in payment page after customer choose a carrier.

In Payment, I have a set of codes to re-check on stock availability and hide the payment div, replacing it with the codes below :

{block name='cart_detailed_product'}
      <div class="cart-overview js-cart"
           data-refresh-url="{url entity='cart' params=['ajax' => true, 'action' => 'refresh']}">
          {if $cart.products}
              <ul class="cart-items">
                  <li class="cart-item-header hidden-sm-down">
                      <div class="row small-gutters">
                          <div class="col-6">{l s='Product' d='Shop.Theme.Checkout'}</div>
                          <div class="col-6">
                              <div class="row small-gutters">
                                  <div class="col">{l s='Price' d='Shop.Theme.Checkout'}</div>
                                  <div class="col">{l s='Qty' d='Shop.Theme.Checkout'}</div>
                                  <div class="col">{l s='Total' d='Shop.Theme.Checkout'}</div>
                                  <div class="col col-auto"><i class="fa fa-trash-o invisible" aria-hidden="true"></i></div>
                              </div>
                          </div>
                      </div>
                  </li>
                  {foreach from=$cart.products item=product}
                      <li class="cart-item">
                          {block name='cart_detailed_product_line'}
                              {include file='checkout/_partials/cart-detailed-product-line.tpl' product=$product}
                          {/block}
                      </li>
                      {if $product.customizations|count >1}
                          <hr>
                      {/if}
                  {/foreach}
              </ul>
          {else}
              <div class="alert alert-warning">{l s='There are no more items in your cart' d='Shop.Theme.Checkout'}</div>
          {/if}
      </div>
{/block}

I placed a refresh button to refresh the page and proceed with payment once the cart has been updated.

<script>
  function refreshPage(){
  window.location.reload();
  } 
</script>
<button type="submit" class="btn btn-secondary btn-xs" 
 onClick="refreshPage()">Update Cart</button>

It is working well and the display is able to update cart. But I am facing an issue whereby once the cart is correct to proceed, it will refresh to Address. Address is the 2nd step in one-page checkout.

Can anyone advise me on how to refresh and stay in Payment?

Thank you.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...