Tagged: x
-
AuthorPosts
-
March 24, 2016 at 4:56 pm #851620
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
March 24, 2016 at 8:51 pm #851837Hello 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.
March 25, 2016 at 4:23 am #852177Hi,
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..
March 25, 2016 at 4:30 am #852188Hello 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.
March 25, 2016 at 4:36 am #852194The function you proposed did not even add the thumbnails display so something is clearly overriding something somewhere after the header?
March 25, 2016 at 4:41 am #852199Hi 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!
March 25, 2016 at 4:54 am #852210No 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..
March 25, 2016 at 5:26 am #852232Hi,
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 credentialsDon’t forget to select Set as private reply. This ensures your information is only visible to our staff.
March 25, 2016 at 7:34 am #852322This reply has been marked as private.March 25, 2016 at 2:38 pm #852757Hi 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!
March 25, 2016 at 5:38 pm #852912OK, 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”)?March 25, 2016 at 9:56 pm #853095Hello 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.
-
AuthorPosts