Tag Archives: woocommerce

WooCommerce email with custom total row

To add a custom total row to woocommerce email total section just hook into woocommerce_get_order_item_totals add_filter(‘woocommerce_get_order_item_totals’, ‘my_woocommerce_get_order_item_totals’, 10, 2); function my_woocommerce_get_order_item_totals($total_rows, $order) { $new_total_rows[‘cart_subtotal’] = $total_rows[‘cart_subtotal’]; $new_total_rows[‘shipping’] = array( ‘label’ => ‘Slovak Parcel Service:’, ‘value’ => wc_price(3), ); $gateway = wc_get_payment_gateway_by_order($order); … Continue reading

Posted in woocommerce | Tagged , | Leave a comment

WooCommerce check if product in cart is in stock

Check if product in cart is in stock: foreach (WC()->cart->cart_contents as $item) { $product_id = isset($item[‘variation_id’]) ? $item[‘variation_id’] : $item[‘product_id’]; $product = new \WC_Product_Factory(); $product = $product->get_product($product_id); if ($item[‘quantity’] > $product->get_stock_quantity()) { $inStock = false; break; } }

Posted in Uncategorized, woocommerce | Tagged , , , | Leave a comment

Fix language of WooCommerce ‘Thank You’ redirect URL for qTranslate

I struggled a bit with wrong translation of the thank you page. For translation I used qTranslate and IM8 qTranslate WooCommerce Looking at the Network tab in Chrome I saw the 301 redirect, but it took a while to figure out … Continue reading

Posted in woocommerce, wordpress | Tagged , , | Leave a comment

Add manufacturer category to WooCommerce product from post title

I had to categorize more than 4000 WooCommerce products (car tyres) which contained manufacturer name as first word in title. So did it with the following code: /**  * Add manufacturer product category to WooCommerce product from post title  * … Continue reading

Posted in woocommerce, wordpress | Tagged , | Leave a comment

Add manufacturer tag to WooCommerce product from title

I had to tag more than 4000 products so I came up with the following WP action: /** * Add manufacturer product_tag to WooCommerce product from post title * * @return void **/ function mz_add_manufacturer_tag() { // Get manufacturer from … Continue reading

Posted in woocommerce, wordpress | Tagged , | 3 Comments

Show WooCommerce product count in theme

Couldn’t Google the solution so after some time a came up with the following solution: // functions.php function my_product_count() { $product_count = 0; // Get count for all product categories foreach (get_terms(‘product_cat’) as $term) $product_count += $term->count; return $product_count; } … Continue reading

Posted in Uncategorized | Tagged , | 7 Comments

Using WooCommerce shortcodes

Yesterday I had some issues running WooCommerce shortcodes and didn’t found solution on YouTube or via Google. After an hour I figured it out. I created a post with the following shortcode: [product_category category=”letne-pneumatiky” order=”asc”] After viewing the post in … Continue reading

Posted in php, wordpress | Tagged , , | Leave a comment