Which WooCommerce hook do I need to use to place the coupon field after the checkout sidebar

There are some important things to point out that will help you get somewhere hopefully close. First, the coupon code entry is a form separate from the checkout form. You cannot place one form inside another as that would conflict the submission process (essentially, you’d be submitting the wrong data to the wrong handling process). … 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

Woocommerce: show default variation price is products list?

Try this code: add_filter(‘woocommerce_variable_price_html’, ‘custom_variation_price’, 10, 2); function custom_variation_price( $price, $product ) { $available_variations = $product->get_available_variations(); $selectedPrice=””; $dump = ”; foreach ( $available_variations as $variation ) { // $dump = $dump . ‘<pre>’ . var_export($variation[‘attributes’], true) . ‘</pre>’; $isDefVariation=false; foreach($product->get_default_attributes() as $key=>$val){ // $dump = $dump . ‘<pre>’ . var_export($key, true) . ‘</pre>’; // $dump … Read more

How to remove_action inside class [duplicate]

It’s not possible to remove it with remove_action() the way you’ve written it. When you hooked it here: add_action( ‘woocommerce_shop_loop_item_title’, array( $this, ‘change_title’ ), 10 ); The $this means that the function that’s hooked is on this specific instance of My_class. When using remove_action() you need to pass the same instance of the class: remove_action( … Read more

Declaring custom woocommerce product type as virtual / downloadable only [closed]

Looking further into the WooCommerce source, they fortunately, provide a filter named woocommerce_product_data_tabs which will allow you to conditional unset tabs. I’ve provided an example below: add_filter(‘woocommerce_product_data_tabs’, function($tabs) { /** * The available tab array keys are: * * general * inventory * shipping * linked_product * attribute * variations * advanced */ unset($tabs[‘shipping’]); return … Read more

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