woocommerce specific quantities for product

Try this in your functions.php: add_filter( ‘woocommerce_quantity_input_args’, ‘control_product_qty_input’, 20, 2 ); function control_product_qty_input( $args, $product ) { $settings = array(’49’ => 3, ’48’ => 10); // for product id 49 3 products set foreach ($settings as $k => $v) { if($k === $product->get_id()){ $args[‘max_value’] = $v; $args[‘min_value’] = $v; } } return $args; } Note: … Read more

Remove page title in product page using a function

There are two ways of doing this – with hooks, or by overriding the WooCommerce template file in your Child theme. First, let’s look at the file override: Method 1 – File Override From the WooCommerce plugin folder, copy the templates/single-product/title.php file, and paste it into your active theme under woocommerce/single-product/title.php Then, simply change this … Read more

How to translate text in function.php with WPML [closed]

It should suffice to add a __() around your translatable text: add_action( ‘woocommerce_cart_calculate_fees’, ‘custom_handling_fee’, 10, 1 ); function custom_handling_fee ( $cart ) { if ( is_admin() && ! defined( ‘DOING_AJAX’ ) ) return; if ( ‘cod’ === WC()->session->get(‘chosen_payment_method’) ) { $fee = 10; $cart->add_fee( __(‘Cash On Delivery’), $fee, true ); } } You can then … Read more

Only show size attributes in product box woocommerce when available

to test is the text is not empty, try that : function display_size_attribute() { global $product; if ($product->is_type(‘external’)) { $taxonomy = ‘pa_maat’; $text = $product->get_attribute($taxonomy); if (!empty($text)) { echo “Maten:”; echo ‘<span class=”attribute-size”>’ . htmlspecialchars($text) . ‘</span>’; } } // END if ($product->is_type(‘external’)) { } // END function display_size_attribute() {

WC_Customer delete function returns error

Welcome! You need to include ‘wp-admin/includes/user.php’ before calling wp_delete_user function. The reason is, it is an admin functionality and it is not available everywhere in code. In Your case, just put the following line of code at the very beginning of the function. require_once ABSPATH . ‘wp-admin/includes/user.php’;

Rename WooCommerce sorting dropdown options [closed]

Add this code to functions.php and rename the relevant option. Here I have renamed the ‘Popularity’ option to ‘Best Selling’. add_filter( ‘woocommerce_catalog_orderby’, ‘rename_sorting_option_woocommerce_shop’ ); function rename_sorting_option_woocommerce_shop( $options ) { $options[‘popularity’] = __( ‘Best Selling’, ‘woocommerce’ ); $options[‘date’] = __( ‘Newest’, ‘woocommerce’ ); $options[‘price’] = __( ‘Price: Low to High’, ‘woocommerce’ ); $options[‘price-desc’] = __( ‘Price: … Read more