Please submit a private ticket if you need to share sensitive information, such as license details and admin credentials.

Okay
  Public Ticket #3733289
Setting plugin priority within before add to cart button area
Open

Comments

  •  2
    Christina started the conversation

    I have a few different plugins to add options and details to products in the "before add to cart button" area and to get things to show in the order I'd like them to, I need to set the priority for a couple of them.  In the attached image I found the place in the product options files where this priority is set.....the highlighted line originally had 10 set for the priority, i changed it to 1, and now the order on my page is how I want it......  What I'm wondering is if someone could give me a snippet I can add to WPCode so this change won't potentially be lost when the plugin updates.  I am completely learning stuff as I go, so this is beyond my skill level and honestly I'm' surprised I even found the right thing to change in the first place 😅

    Attached files:  productoptions.png

  •  1,526
    Dustin replied

    Hi Christina,

    Please add the custom code below. (How to add custom code? ↗):

    remove_action( 'woocommerce_before_add_to_cart_button', [ Wpcpo_Frontend::instance(), 'display' ], 10 );
    add_action( 'woocommerce_before_add_to_cart_button', [ Wpcpo_Frontend::instance(), 'display' ], 1 );

    If it doesn't work, please try another one:

    add_action( 'init', function () {
    	remove_action( 'woocommerce_before_add_to_cart_button', [ Wpcpo_Frontend::instance(), 'display' ], 10 );
    	add_action( 'woocommerce_before_add_to_cart_button', [ Wpcpo_Frontend::instance(), 'display' ], 1 );
    } );

    Best regards,
    Dustin

  •  2
    Christina replied

    The first didn't work, but the second did!  Thank you!

  •  2
    Christina replied

    This code stopped working not too long ago...It will still add the the product options items in the new location, but it no longer removes the original location, so, it shows all of the options twice.  Do you have any suggestions for how to correct this now?
    This is what was showing when I first discovered the issue

  •  1,526
    Dustin replied

    Please update this snippet with a new one:

    add_action( 'init', function () {
    	if ( class_exists( 'Wpcpo_Frontend' ) ) {
    		remove_action( 'woocommerce_before_add_to_cart_button', [ Wpcpo_Frontend::instance(), 'display' ], 10 );
    		add_action( 'woocommerce_before_add_to_cart_button', [ Wpcpo_Frontend::instance(), 'display' ], 1 );
    	}
    } );

    If it doesn't work, please send me your website credentials (wp-admin link, username, and password) or create a development or staging site with identical configurations so I can check for any issues.

    Best regards,
    Dustin