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

How do I hook a custom discount to change a WC_Order price total on WooCommerce?

I would suggest adding a “virtual” coupon to the order which would represent the store credit. Coupons are applied on the cart page before checkout, this is where I would hook in. You can use something like the woocommerce_cart_subtotal filter as per my example below: function royal_woocommerce_filter_checkout_for_coupons( $subtotal, $compound, $cart ) { // Your logic … Read more

Plugin vs Settings load order (woocommerce dependency)

The problem is, by the time your WooCommerce_Chilexpress_Tags_Settings is defined, WC_Settings_Page has indeed not yet loaded; hence you got the fatal error. And if you want to do it the same way that WooCommerce does it, place the WooCommerce_Chilexpress_Tags_Settings in a separate PHP file, e.g. includes/class-woocommerce-chilexpress-tags-tettings.php, and initialize the class from that file — i.e. … 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)