D
D
Dmitry2021-01-27 01:17:02
MODX
Dmitry, 2021-01-27 01:17:02

How to make a redirect after emptying the trash in minishop2?

Greetings gentlemen. Tell me, how can I redirect to the main page after clicking on the "empty basket" button?
Googled the ways, the only thing I found:

//данный способ мне не подходит (это условие "если корзина пуста")
{if !count($products)}
        <script>
        	document.location.href="/index.html";
        </script>
{else}

But this method does not suit me!) I tried it with a script via button onlick - to no avail. There are options?))

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry, 2021-01-28
@Bondich228

I asked the question myself, and I will answer it myself)))) Helped on third-party forums.
SOLUTION:
find the empty cart button in the msCart chunk, in my case it will be

<form method="post">
      <button type="submit" name="ms2_action" value="cart/clean" class="btn btn-danger">Очистить</button>
 </form>

need to add action attribute to form
<form method="post" action="/">
      <button type="submit" name="ms2_action" value="cart/clean" class="btn btn-danger">Очистить</button>
 </form>

I quote Alexei, who helped))
The minishop script looks at the form action of the empty cart button, if it is not there, it substitutes it from its settings. This applies specifically to the clear button. If the products are deleted one by one, then there is either a plugin or editing the js file, as described above.

D
Danny Arty, 2021-01-27
@DanArst

You can catch the cart.clean.response.success callback .
It seems like this should work, you need to check:

miniShop2.Callbacks.Cart.clean.response.success = function () {	
  location.href = "stranica.html";
  return false;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question