Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #851620

    mrboats
    Participant

    Trying to remove the upsell element at the end of the product page with a function like this:

    Apparently the position number (25 in the example) at the end must be exact to successfully remove it, any idea of what the correct position number might be:

    remove_action( ‘woocommerce_after_single_product_summary’, ‘woocommerce_upsell_display’, 25 );

    Thanks

    #851837

    Rue Nel
    Moderator

    Hello There,

    Thanks for writing in! Please update the code and use this instead:

    
    remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_upsell_display', 15 );

    You can find this at line 131 in wp-content/plugins/woocommerce/includes/wc-template-hooks.php file.

    Hope this helps.

    #852177

    mrboats
    Participant

    Hi,

    No, it didn’t. There is something else going on here. I have the Renew stack. By adding a different element to the Single product view after_single_product_summary, I can deduce that actually the upsell_display seems to be at positions 21 or 22. This can be deduced by adding an element at position 21 – it goes before the upsell_display and adding the element instead at position 22 – it goes after (see code below). So it seems that X/Renew rearranges the single product page in some way to alter the default layout (which btw can be deduced also by the fact that the upsell_display appears after the Related product which is not the same order as in the Woo default, position 15 would appear above 20).

    See attached screenshot of layout when thumbnails are placed at position 21.

    
    /* None of these removes the upsell_display *)
    remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_upsell_display', 15 );
    remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_upsell_display', 21 );
    remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_upsell_display', 22 );
    
    /* thumbnails appear before Upsell_display with the below position 21 */
    add_action( 'woocommerce_after_single_product_summary', 'woocommerce_show_product_thumbnails', 21 ); 
    
    /* thumbnails appear after Upsell_display with the below position 22 */
    add_action( 'woocommerce_after_single_product_summary', 'woocommerce_show_product_thumbnails', 22 ); 
    

    Confused..

    #852188

    Rue Nel
    Moderator

    Hello There,

    Please have your custom function like this:

    // Move upsell display
    // =============================================================================
    function move_upsell_display(){
      remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_upsell_display', 15 );
      add_action( 'woocommerce_after_single_product_summary', 'woocommerce_show_product_thumbnails', 22 ); 
    }
    //add_action('wp_head', 'move_upsell_display');
    // =============================================================================

    And please make sure that you do not have any other hooks after tis function. I would highly advise that you insert this at the very bottom of your child theme’s functions.php file.

    Hope this helps.

    #852194

    mrboats
    Participant

    The function you proposed did not even add the thumbnails display so something is clearly overriding something somewhere after the header?

    #852199

    Zeshan
    Member

    Hi there,

    Sorry about the function! It seems the add_action hooks is commented out. Please try this code instead:

    // Move upsell display
    // =============================================================================
    
    function move_upsell_display(){
      remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_upsell_display', 15 );
      add_action( 'woocommerce_after_single_product_summary', 'woocommerce_show_product_thumbnails', 22 ); 
    }
    
    add_action('wp_head', 'move_upsell_display');
    
    // =============================================================================
    

    Thank you!

    #852210

    mrboats
    Participant

    No luck. I modified your code as follows:

    
    // Move upsell display
    // =============================================================================
    
    function move_upsell_display(){
      remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_upsell_display', 15 );
      remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_upsell_display', 20 );  
      remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_upsell_display', 21 );  
      remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_upsell_display', 22 );
    
      add_action( 'woocommerce_after_single_product_summary', 'woocommerce_show_product_thumbnails', 20 ); 
      add_action( 'woocommerce_after_single_product_summary', 'woocommerce_show_product_thumbnails', 22 ); 
    }
    
    add_action('wp_head', 'move_upsell_display');
    
    // =============================================================================
    

    As you can see from the screenshot, I get the up_sell surrounded by two thumbnail views, but as you can see, I don’t get rid of the upsell..

    #852232

    Paul R
    Moderator

    Hi,

    Would you mind providing us with login credentials so we can take a closer look? To do this, you can make a post with the following info:

    – Link to your site
    – WordPress Admin username / password
    – FTP credentials

    Don’t forget to select Set as private reply. This ensures your information is only visible to our staff.

    #852322

    mrboats
    Participant
    This reply has been marked as private.
    #852757

    Rad
    Moderator

    Hi there,

    I went ahead and changed your code to this,

    // Move upsell display
    // =============================================================================
    
    function move_upsell_display(){
      remove_action( 'woocommerce_after_single_product_summary', 'x_woocommerce_output_upsells', 21 );  
      add_action( 'woocommerce_after_single_product_summary', 'x_woocommerce_output_upsells', 25 ); 
    }
    
    add_action('wp_head', 'move_upsell_display');
    
    

    Cheers!

    #852912

    mrboats
    Participant

    OK, thanks. Not quite what I was trying to do but this allowed me to fix the problem.

    A couple of questions still for future reference:
    – Is there any reason to use the X specific functions (as in “x_woocommerce_output_upsells” instead of “woocommerce_upsells_display”) as using the Woo standard functions seems to produce exactly the same result as far as I can see?
    – Where do I find a list of the X specific Woo display element functions (ie a list of the renamed functions like “x_woocommerce_output_upsells”)?

    #853095

    Rue Nel
    Moderator

    Hello There,

    Thanks for the updates. There are some functions that were removed or added in X. You can find the list of these functions by checking out the X/FRAMEWORK/FUNCTIONS/GLOBAL/PLUGINS/WOOCOMMERCE.PHP file. In this file, you can find some of the Woocommerce function overrides for X which we have created to modify the standard Woo function.

    Hope this helps.