• Resolved 019mrb

    (@019mrb)


    Today I enabled a product on catalog mode
    And the pages where this product was shown , the price of all products wasn’t shown

    I investigated the issue and the problem could be on wc-frontend-manager\core\class-wcfm-catalog.php

    Line 116:
    remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price', 10 );

    This line remove all the prices on the all loop, not only in the product

Viewing 15 replies - 1 through 15 (of 18 total)
  • Thread Starter 019mrb

    (@019mrb)

    I changed the if (line 111) from:

    		if( $product_id ) {
    			$is_catalog = ( get_post_meta( $product_id, '_catalog', true) == 'yes' ) ? 'yes' : '';
    			if( $is_catalog == 'yes' ) { 
    				$disable_price = ( get_post_meta( $product_id, 'disable_price', true) ) ? get_post_meta( $product_id, 'disable_price', true) : 'no';
    				if( $disable_price == 'yes' ) {
    					remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price', 10 );
    				}
    			}
    		}

    To:

    		if( $product_id &&
    		get_post_meta( $product_id, '_catalog', true) == 'yes' &&
    		get_post_meta( $product_id, 'disable_price', true) )
    			remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price', 10 );
    		else
    			add_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price', 11 );
    • This reply was modified 6 years, 11 months ago by 019mrb.
    • This reply was modified 6 years, 11 months ago by 019mrb.
    • This reply was modified 6 years, 11 months ago by 019mrb.
    Thread Starter 019mrb

    (@019mrb)

    Another bug
    changed condition get_post_meta( $product_id, 'disable_price', true) to get_post_meta( $product_id, 'disable_price', true) == 'yes'

    Plugin Author WC Lovers

    (@wclovers)

    HI,

    Thanks for improvement suggestion, we are looking into this.

    Thank You

    Thread Starter 019mrb

    (@019mrb)

    I update to 5.4.7 fixs that?

    Plugin Author WC Lovers

    (@wclovers)

    NO, our team still debugging this. It will be part of next update!

    Thread Starter 019mrb

    (@019mrb)

    I’m waiting

    Thread Starter 019mrb

    (@019mrb)

    Bug with my code: sometimes the hook was double, so I solved:

    		if( $product_id &&
    		get_post_meta( $product_id, '_catalog', true) == 'yes' &&
    		get_post_meta( $product_id, 'disable_price', true) == 'yes' )
    			remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price', 10 );
    		else
    			if(!has_action('woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price'))
    				add_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price', 11 );
    Plugin Author WC Lovers

    (@wclovers)

    Thanks.

    Thread Starter 019mrb

    (@019mrb)

    this isn’t resolved, you need update your files
    i detected a new update, but the problem persist

    Thread Starter 019mrb

    (@019mrb)

    New version and the bug still unfixed

    Plugin Author WC Lovers

    (@wclovers)

    Hi,

    Sorry, it’s our fault. We had mark this resolved after implemented this in core but missed to notify you.

    Well, this fix is part of latest WCFM update, 6.0.3

    Please update yours and take a look.

    Thank You

    Thread Starter 019mrb

    (@019mrb)

    I updated, the issue isn’t fixed. I checked your code and is wrong:

    		if( $product_id ) {
    			$is_catalog = ( get_post_meta( $product_id, '_catalog', true) == 'yes' ) ? 'yes' : '';
    			if( $is_catalog == 'yes' ) { 
    				$disable_price = ( get_post_meta( $product_id, 'disable_price', true) ) ? get_post_meta( $product_id, 'disable_price', true) : 'no';
    				if( $disable_price == 'yes' ) {
    					remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price', 10 );
    				} elseif( !has_action('woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price') ) {
    					add_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price', 10 );
    				}
    			}
    		}

    The added/removed actions performs beyond the current product impression. When you modify the actions, you are modify the “routine actions” of the all loop.

    Example:

    Our loop has 3 products:
    1- Price disabled: true
    Then you remove de action
    2- Price disabled: false
    The action still removed
    3- Price disabled: false
    The action still removed

    The logic of your code isn’t considering this fact

    Thread Starter 019mrb

    (@019mrb)

    My last proposal solution:

    		if( $product_id &&
    		get_post_meta( $product_id, '_catalog', true) == 'yes' &&
    		get_post_meta( $product_id, 'disable_price', true) == 'yes' ) {
    			if(has_action('woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price') )
    				remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price', 10 );
    		} else
    			if(!has_action('woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price') )
    				add_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price', 10 );
    Plugin Author WC Lovers

    (@wclovers)

    HI,

    The added/removed actions performs beyond the current product impression. When you modify the actions, you are modify the “routine actions” of the all loop.

    – Then what this condition is for?

    $disable_price = ( get_post_meta( $product_id, ‘disable_price’, true) ) ? get_post_meta( $product_id, ‘disable_price’, true) : ‘no’;
    if( $disable_price == ‘yes’ ) {

    Thread Starter 019mrb

    (@019mrb)

    These conditions belongs to each product on the loop, because not all products can have the same option value

Viewing 15 replies - 1 through 15 (of 18 total)

The topic ‘Catalog mode on product conflict’ is closed to new replies.