How to get the particular product quantity in orders in Woocommerce

I am working on my WooCommerce project and I am sending mail to the customer and in that I am sending the particular product quantity. So, I am not able to get that particular product quantity from the order. This is code: $order = new WC_Order( $order_id ); $item_quantity=0; $targeted_id = 14988; foreach ( $order->get_items() … Read more

get_the_post_thumbnail_url does not return anything if image size is set

I want to display the post-thumbnail image in the header using get_the_post_thumbnail_url() with defined size, however if I am using it without specifying the size, like get_the_post_thumbnail_url() it is displaying the thumbnail img, but if I am using it like: get_the_post_thumbnail_url('thumbnail') nothing is shown.

Send email notifications to a defined email address depending if a product in order has a specific TAG

I looking to send new order woocommerce email notification to two diferent emails depending if a product in the order has a specific TAG or not. So far what I came up with was the following: //Custom NEW ORDER Email address depending on Product Tag add_filter( 'woocommerce_email_recipient_new_order', 'new_order_conditional_email_recipient', 10, 2 ); function new_order_conditional_email_recipient( $recipient, $order … Read more

wc_get_product_id_by_sku() returns 0 for products added programatically via update_post_meta

I am parsing some products from XML and adding them into the database in woocommerce programmatically. SKU along with other data is saved with update_post_meta($post_id, '_sku', (string)$product->id); and is visible in the back-end. The problem is that when I try to check if there exists product with some SKU added this way programatically I always get 0.

Adapt shipping surcharge code

Looking to adapt the following code, so currently this adds 1% to the basket if the country is US I need £35 amount not a percentage and to only apply with Country UK and postcode BT* (all BT postcodes) add_action( 'woocommerce_cart_calculate_fees','woocommerce_custom_surcharge' ); function woocommerce_custom_surcharge() { global $woocommerce; if ( is_admin() && ! defined( 'DOING_AJAX' ) … Read more

Display “Add to basket” and “Read more” buttons in the products shop page with woocommerce

I’ve been playing a little bit with the woocommerce storefront theme and woocommerce, and I wanted to display the “Add to basket” and “Read more” at the same time on the shop page for each product when possible. I came out with a solution, but I wonder if there is a different way to do this so I don’t have to use CSS to hide a “Read more” button next to another “Read more”. Ideally, I wouldn’t need CSS and there would be only one “Read more” button when it’s not possible to add to the cart.