Category 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

Get currency rates from ECB

For a WooCommerce powered site I needed a currency rate fetching function so here is what I used. /** * Get currency rate * * Info @ http://www.ecb.int/stats/exchange/eurofxref/html/index.en.html * The reference rates are usually updated by 3 pm CET * … Continue reading

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

Converting gettext .po files to binary .mo files via command line

Updated a WP plugin and translation needed fixation. I edited the .po file, but no change was on the site. I needed to convert it to .mo file. Thanks to Joss Crowcroft and his post http://www.josscrowcroft.com/2011/code/php-mo-convert-gettext-po-file-to-binary-mo-file-php/ I was able to convert. $ msgfmt -cv … Continue reading

Posted in woocommerce, wordpress | Tagged | Leave a comment

WooCommerce advanced (product attribute) search

I couldn’t find answers why Googling, how to make search work with product attributes of WooCommerce products. Wrote the code, but it was always 404 page. URLs with /taxonomy/term_slug (example.com/radius/16/) were working, but example.com/?s=&post_type=product&pa_radius=TERM_ID&pa_width=TERM_ID&pa_manufacturer=TERM_ID wasn’t outputing any products. header.php  <form … Continue reading

Posted in woocommerce, wordpress | Tagged , | 9 Comments

Different wp_title and WooCommerce page title by terms

In a project I needed wp_title with the separator, but WC page title without separator for specific terms of a taxonomy. Here’s the code I used: /** * Add more descriptive page title to some taxonomy term * * @param … Continue reading

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