Woocommerce SKU on ALL products page [closed]

Hope this code will helpful for you, the sku will be displayed at the end of shop loop function shop_display_skus() { global $product; if ( $product->get_sku() ) { echo ‘<div class=”product-meta”>SKU: ‘ . $product->get_sku() . ‘</div>’; } } add_action( ‘woocommerce_after_shop_loop_item’, ‘shop_display_skus’, 9 );

woocommerce change order statuses count for specific role

Normally pre_get_post doesn’t change wordpress views post count. You have to call another filter hook to change to count. add_action(‘pre_get_posts’, function ($query) { global $pagenow; if (isset($query->query_vars[‘post_type’])) { if ($query->query_vars[‘post_type’] == ‘shop_order’ && (‘edit.php’ == $pagenow)) { if (!$query->is_main_query()) { return; } // I manipulate $query here // Get Post Count Here For Each Status … Read more

OrderItem get_total() returns lower value than $order_item->get_product()->get_price() * quantity

The problem seems to be related to missing tax or (and) to applied coupon discount. The WC_Order_Item_Product method get_total() is the discounted line item total without taxes. In this case when a coupon is used, the discount is applied to the item depending of the coupon type and restrictions. The WC_Order_Item_Product method get_subtotal() is the … Read more

Get child product categories from parent product category in WooCommerce

Edited (1) You will need to use ‘child_of’ from WP_Term_Query available arguments, that will let you to get all child terms for the current product category parent term: // Only on product category archive pages if( is_product_category() ) { $main_term = get_queried_object(); $args_query = array( ‘taxonomy’ => ‘product_cat’, ‘hide_empty’ => false, ‘child_of’ => $main_term->parent ); … Read more

get_cat_ID() not wokring

get_cat_ID gets the ID of a category based on the name. “Category” is a specific taxonomy named category. You’re trying to get the ID of a Product Category (product_cat). You cannot use get_cat_ID() to get the ID of a custom taxonomy. To do that you need to use get_term_by(): $product_cat = get_term_by( ‘name’, $cat_name, ‘product_cat’ … Read more

Create WooCommerce new order with specific ID

Well.. You can add meta for original and cloned order. Just add +1 for it, each time when you will clone items. function create_order( $original_order_id, … try { $new_order = new WC_Order(); $new_order->set_props( array( … } $original_order = wc_get_order( $original_order_id ); $order_item_num = $original_order->get_meta(‘_order_items_num’); if($order_item_num >= 1) { $new_order->update_meta_data( ‘_order_item_num’, $order_item_num+1 ); $new_order->save(); $original_order->update_meta_data( ‘_order_items_num’, … Read more

Need Old Version of plugins

If you are looking for old versions of a plugin in the WordPress repository (like WooCommerce), you can go to the plugin’s page on WordPress.org/plugins, then look in the right column under the plugin’s Tags for the link to “Advanced View”. Click on that, then scroll all the way down and select from the dropdown … Read more

Woocommerce Product Image and Thumbnails custom function

In short: We are going to overwrite the default template and change the function that is being called to generate our tag and the image inside it. Next, we are going to create this function into our functions.php and add the attribute we want to the tag. copy/paste the template woocommerce/templates/single-product/product-image.php to your directory: your-child-theme/woocommerce/single-product/product-image.php … Read more