Disable link in quantity field

I add this code: https://docs.woocommerce.com/document/override-loop-template-and-show-quantities-next-to-add-to-cart-buttons/

for suport quantity field. But there is link href function and when I click on quantity field, so it redirect. How disable it?

1 answer

  • answered 2018-07-11 10:48 heroj

    I resolve it with this snippet:

    // WooCommerce remove the product quantity link
    add_action( 'woocommerce_quantity_input_inputmode', 'wcname_close_link', 9);
    function wcname_close_link() {
        echo "</a>";
    add_action( 'woocommerce_quantity_input_inputmode', 'wcname_open_empty_link', 4);
    function wcname_open_empty_link() {
        echo "<a href='#'>";