WooCommerce – Query for ordered products

Fixed query select p.ID as order_id, p.post_date, i.order_item_name, max( CASE WHEN im.meta_key = ‘_product_id’ and i.order_item_id = im.order_item_id THEN im.meta_value END ) as Prod_ID from wp_posts as p, wp_postmeta as pm, wp_woocommerce_order_items as i, wp_woocommerce_order_itemmeta as im where p.post_type=”shop_order” and p.ID = pm.post_id and p.ID = i.order_id and p.post_date BETWEEN ‘2016-01-14 00:00:00’ AND ‘2016-01-14 23:59:59’ … Read more

Changing Woocommerce price display [closed]

I found the hooks you were looking for by reviewing the WooCommerce template source code (review-order.php). Here’s the code: add_filter( ‘woocommerce_get_price_html’, ‘kd_custom_price_message’ ); add_filter( ‘woocommerce_cart_item_price’, ‘kd_custom_price_message’ ); add_filter( ‘woocommerce_cart_item_subtotal’, ‘kd_custom_price_message’ ); // added add_filter( ‘woocommerce_cart_subtotal’, ‘kd_custom_price_message’ ); // added add_filter( ‘woocommerce_cart_total’, ‘kd_custom_price_message’ ); // added function kd_custom_price_message( $price ) { $afterPriceSymbol=”.-“; return $price . $afterPriceSymbol; … Read more

woocommerce_before_calculate_totals in woocommerce 3.0

Well, the problem is you are calling price directly at $value[‘data’]->price. Make it $value[‘data’]->get_price() and I think you problem will be fixed. So the whole code block will be- function calculate_embossing_fee( $cart_object ) { if( !WC()->session->__isset( “reload_checkout” )) { /* Gift wrap price */ $additionalPrice = 5; foreach ( $cart_object->cart_contents as $key => $value ) … Read more

Woocommerce – How to add 5 stars to all products to test design

@Nikola‘s answer gives you what you want to need without saving anything to the database. If you need to save the values to the database and directly execute SQL, you can do the following. Basically WooCommerce stores product reviews data as a postmeta under meta keys _wc_rating_count _wc_average_rating _wc_review_count UPDATE fs_postmeta SET meta_value = 5 … Read more

How to hook on a WooCommerce checkout field?

There is no hook woocommerce_form_field, there is hook woocommerce_form_field_{$args[type]} (doc). $args[type] can be (look here for available options): text, checkbox, country, … Code below will wrap ‘billing_first_name‘ and ‘billing_last_name‘ fields in a wrapper like <div class=”first-and-second-field-wrapper”> […] </div>. function change_woocommerce_field_markup($field, $key, $args, $value) { $field = ‘<div class=”single-field-wrapper”>’.$field.'</div>’; if($key === ‘billing_first_name’) $field = ‘<div class=”first-and-second-field-wrapper”>’.$field; … Read more

Get product attribute for Simple product in WooCommerce

Building on Loic’s answer for an attribute of pa_manufacturer: if ( get_post_type( $post ) === ‘product’ && ! is_a($product, ‘WC_Product’) ) { $product = wc_get_product( get_the_id() ); // Get the WC_Product Object } $product_attributes = $product->get_attributes(); // Get the product attributes // Output $manufacturer_id = $product_attributes[‘pa_manufacturer’][‘options’][‘0’]; // returns the ID of the term $manufacturer_name = … Read more

Enqueue script on specific WooCommerce template

You need to delay the firing of your code, otherwise your conditionals will evaluate false (the request won’t have been parsed yet). Use the action wp_enqueue_scripts: function wpse_182357_enqueue_scripts() { // Your code } add_action( ‘wp_enqueue_scripts’, ‘wpse_182357_enqueue_scripts’ ); Update: Missed the root of the problem – is_page_template() only works for pages. Rather than checking if the … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)