admin管理员组

文章数量:1406037

Closed. This question is off-topic. It is not currently accepting answers.

Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third-party plugins and themes are off-topic for this site; they are better asked about at their developers' support routes.

Closed 5 years ago.

Improve this question

I have a custom product list page which basically is a category page listing all products in that category. I have the below to add quantity selection and an add to cart button.

add_filter( 'woocommerce_loop_add_to_cart_link', 'quantity_inputs_for_woocommerce_loop_add_to_cart_link', 10, 2 );

function quantity_inputs_for_woocommerce_loop_add_to_cart_link( $html, $product ) {

    $term_id = get_queried_object()->term_id;
    $post_id = 'product_cat_'.$term_id;
    $wk_cat_value = get_term_meta($term_id, 'wh_meta_cat_template', true);

    if ($wk_cat_value == 1 && is_product_category())

    {

        if ( $product && $product->is_type( 'simple' ) && $product->is_purchasable() && $product->is_in_stock() && ! $product->is_sold_individually() ) {
            $html = '<form action="' . esc_url( $product->add_to_cart_url() ) . '" class="cart" method="post" enctype="multipart/form-data">';
            $html .= woocommerce_quantity_input( array(), $product, false );
            $html .= '<button type="submit" class="button alt">' . esc_html( $product->add_to_cart_text() ) . '</button>';
            $html .= '</form>';
        }

        return $html;

    }
}

It was working fine until I updated Woocommerce to the latest version. Now it's not showing up. Not the quantity, nor the add to cart button.

Any ideas what is wrong?

本文标签: functionsAdd to cart php not working