L
L
ligisayan2016-08-22 17:50:54
PHP
ligisayan, 2016-08-22 17:50:54

How, after recalculating the data and refreshing the page, open it in a specific tab?

Hello! There is a site on wordpress + woocommerce with a coupon plugin installed for a basket of this kind:

<div class="coupon">
             <input type="text" name="coupon_code" class="input-text" id="coupon_code" value="" placeholder="<?php _e( 'Coupon code', 'woocommerce' ); ?>" /> <input type="submit" class="button" name="apply_coupon" value="&#xf04b" />
<?php do_action('woocommerce_cart_coupon'); ?>
</div>

The peculiarity is that my cart (together with the coupon field) is on a page with a tab tab (#mycart), which is not the first in the queue. If you click on the input type="submit" button , then by default, after the element is recalculated, the page is updated and it opens from the first tab. How to make the page open from the tab with the #mycart page after refresh?
As I understand it, you need to override the woocommerce_cart_coupon hook , but I can’t find a function that sets the hook’s functionality in the search. What do you advise?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
L
ligisayan, 2016-08-24
@ligisayan

everything is much simpler - in the file cart.php it was necessary to correct the line - add it to action .'#mycart'

<form action="<?php echo esc_url( WC()->cart->get_cart_url() ).'#mycart'; ?>" method="post">

I
Ivan Kozlov, 2016-08-23
@trampick

You can use js script like this:

/*здесь условия определения что нужно открыть вкладку (Скорее всего что то в $_REQUEST хранится после обновления страницы)*/
if (mycart) {
echo '<script>$('идентификатор кнопки таба по которой надо кликнуть').click();</script>
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question