Category Archives: woocommerce

SQL to get WooCommerce product categories (terms)

For an import script I needed to get WooCommerce product categories so I ended up looking the generated query in /var/log/mysql/query.log for get_the_terms($postID, ‘taxonomy_name’) I ended up using the following SQL query to get product categories: SELECT t.*, tt.* FROM … Continue reading

Posted in mysql, sql, Uncategorized, woocommerce, wordpress | Tagged , , , , | Leave a comment

Change locale for WooCommerce email

To change WooCommerce email language you need to change the locale after order submit. Using $_GET might be dirty, but works ūüôā

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

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