Display WooCommerce size product attribute on shop page

Your code is outdated since WooCommerce 3. First, you need to target variable products type only to avoid errors on other products types and also $product is already the product object. Also you can also directly use the WC_Product method get_attribute() and your code will be much more simpler, compact and efficient: add_action( ‘woocommerce_after_shop_loop_item_title’, ‘display_size_attribute’, … Read more

Get WooCommerce Email Classes in Backend

Like I’ve pointed in my comment, you can use wc()->mailer()->emails, which would give you a list of all the email class instances. Example: // Get all the email class instances. $emails = wc()->mailer()->emails; // Prints all the email class names. var_dump( array_keys( $emails ) ); // Access the default subject for new order email notifications. … Read more

Programmatically change Payment Methods WooCommerce

Theres a filter called woocommerce_available_payment_gateways: add_filter(‘woocommerce_available_payment_gateways’,’filter_gateways’,1); function filter_gateways($gateways){ global $woocommerce; //Remove a specific payment option unset($gateways[‘paypal’]); return $gateways; } I’m not sure where and how you get / store the Request for Quote option, but you can access the value inside the filter_gateways function and you can remove a specific gateway with a conditional logic.

When Free shipping is available hide other shipping methods except Local pickup in WooCommerce [closed]

The following code will disable other shipping methods excluding “Local Pickup” when “Free shipping” shipping method is available. Required: Free shipping method need to be set with a minimal order amount. add_filter( ‘woocommerce_package_rates’, ‘show_hide_shipping_methods’, 100 ); function show_hide_shipping_methods( $rates ) { $free_rate_id = ”; $other_rates_ids = []; // Loop through available shipping rates foreach ( … Read more

How to add Woocomrce cart page shipping calculator to my country state list

Add this snippet to the functions.php file of your theme to add a new country to the WooCommerce countries list. add_filter(‘woocommerce_states’, ‘sa_woocommerce_states’); add_filter(‘woocommerce_countries_allowed_country_states’,’sa_woocommerce_state’); function SA_woocommerce_states( $states ) { $states[‘ZA’][‘EC’] = __(‘Eastern Cape’, ‘woocommerce’); return $states; }

Optimizing Woocommerce order items query

I’m doing something similar. I started off with an approach similar to yours, but made it slightly faster by directly using WC API Query instead of WP Query. I am still looking for a way to query the variation from all orders… //get number of orders per variation_id function getOrdersfromVariation($variation_id){ $numberOfOrders = 0; ip_write_log(“getOrdersfromVariation varid: … Read more