10Horizons Plugins
Forum Replies Created
-
A bit of explanation before I’m signing off.
If you are using Woocommerce shortcodes like
[products]
,[featured_products]
,[sale_products]
,[add_to_cart id="99"]
, etc on your custom page, you can disable AJAX via Woocommerce settings.Go to Woocommerce > Settings > Products > General > Shop Pages > Add to cart behavior, and then untick Enable AJAX add to cart buttons on archives.
And then you can apply the steps in my reply above.
Let me know how it goes. Happy to help you to get this working.
Forum: Plugins
In reply to: [Woocommerce Upsell / cross sell Popup plugin] Show Popup on Custom PagesHere is the LATEST, revised code. Same as above, but with new localization strings added.
function wup_upsell_popup_scripts_enqueue () { if (( is_page( 13 ) ) && (! thp_wuppro_active() )) { //CHANGE 13 TO THE ID OF YOUR PAGE! $ajax_enabled = get_option( 'woocommerce_enable_ajax_add_to_cart' ); if ( 'yes' === $ajax_enabled ) { wp_enqueue_script( 'thp-popup-js', get_site_url().'/wp-content/plugins/very-simple-woocommerce-upsell-popup/js/wup-ajax.min.js', array('jquery'), '', false ); wp_localize_script( 'thp-popup-js', 'thp_popup_vars', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ), 'added_to_cart' => __( 'Added to Cart!', 'very-simple-woocommerce-upsell-popup' ), 'choose_one' => __( 'Please choose one option!', 'very-simple-woocommerce-upsell-popup' ) ) ); wp_enqueue_script( 'wup-noajax-js', get_site_url().'/wp-content/plugins/very-simple-woocommerce-upsell-popup/js/wup-noajax.min.js', array('jquery'), '', false ); } elseif ( 'yes' != $ajax_enabled ) { wp_enqueue_script( 'wup-noajax-js', get_site_url().'/wp-content/plugins/very-simple-woocommerce-upsell-popup/js/wup-noajax.min.js', array('jquery'), '', false ); wp_localize_script( 'wup-noajax-js', 'wup_noajax_js_vars', array( 'choose_one' => __( 'Please choose one option!', 'very-simple-woocommerce-upsell-popup' ) ) ); } } }
If you want it on a custom page, the steps would be the same but you would have to do with not using AJAX. Is AJAX a must for this custom page to work?
Yes, it’s possible with some tweaks.
First, you have to set the plugin not to use AJAX. On the main setting page of the plugin, you will see an option to turn off AJAX.
Go to Woocommerce > Upsell Popup > General.
Here you will see an option to turn off AJAX. Tick the box that says “Turn off AJAX on single product pages”.
The second thing to do is you have to modify a line of code in the plugin’s core file. Follow the steps below:
1. On your server, go to this directory: /wp-content/plugins/very-simple-woocommerce-upsell-popup/ and open the file in this directory with the name wup-noajax.php.
2. On line 11, you will see this code:
if ((! is_ajax()) && ($thp_addtocart_popup_btn != true)) {
Change the above code with the following code:
if (! is_ajax()) {
3. Save your file.
That’s it.
Forum: Plugins
In reply to: [Woocommerce Upsell / cross sell Popup plugin] Need custom redirect optionThis is currently being resolved through PRO support.
I’m marking this as “resolved” as there is no reply from thread starter for 6 days.
We cannot guarantee our plugin to work with every Woocommerce extension out there.
But having said that, this is what you could try to fix the problem:
Go to Woocommerce > Upsell Popup > General.
Here you will see an option to turn off AJAX. Tick the box that says “Turn off AJAX on single product pages”.
It would also help to share the exact URL of the page on your site where our popup supposed to show?
Thanks.
We have replied your email through pre-sale support, please check your email to continue the conversation.
Thanks!
We cannot guarantee our plugin to work with every Woocommerce extension out there. But having said that, this is what you could try to fix the problem:
Go to Woocommerce > Upsell Popup > General.
Here you will see an option to turn off AJAX. Tick the box that says “Turn off AJAX on single product pages”.
Let me know how it goes.
Forum: Plugins
In reply to: [Woocommerce Upsell / cross sell Popup plugin] Add to cart is not workingWe don’t have that kind of feature unfortunately, but if you are comfortable with editing codes, you could hack the default popup template and change the dropdown list to swatches. It’s not really advisable though, because your changes will be gone each time you update the plugin.
But anyway, glad to hear it’s working!
Forum: Plugins
In reply to: [Woocommerce Upsell / cross sell Popup plugin] Add to cart is not workingI tested the product in your link above and it seems to be working properly for me though?
So if I add “Szatkownica do warzyw Hebel V3 z wk?adk? blokuj?c?” to cart, a popup appears, promoting another product “Miska do Szatkownicy do warzyw Hebla V3”.
Now, since your upsell product “Miska do Szatkownicy do warzyw Hebla V3” is a variable product, your user will be redirected to the upsell product’s product page for user to choose the variation (color).
From our plugin description:
- For complementary product that the product type is SIMPLE: If the user clicks yes, the complementary product will also be added to cart.
- For complementary product that the product type is VARIABLE: If the user clicks yes, you can choose whether to redirect your user to the complementary product’s product page, OR to let your user choose a variant on the popup and add that variant to cart without navigating away from popup.
If you don’t want them to get redirected to the product page of the upsell product, please use popup template with the name of “Variable Upsell” when you configure your popup.
Let me know how it goes.
Forum: Reviews
In reply to: [Protect Admin] very usefulYou’re so very welcome! Thank you for your review!
I’m making this topic sticky so that other people who want the same functionality will see it.
We will consider that for future updates of the plugin.
In the meantime, these codes will do what you want:
Add the following php codes to your functions.php file. This will add a class to the body tag to indicate if popup is enabled or disabled for that specific product. Modified from the plugin core:
function thp_wup_popup_add_class( $classes ) { if (! function_exists( 'is_product' ) ) return; if (is_product()) { $product_id = get_the_ID(); $wup_options = ( !empty(get_option( 'thp_wup_options' )) ? get_option( 'thp_wup_options' ) : '' ); $global_settings_on = ( !empty($wup_options['global_settings_on']) ? $wup_options['global_settings_on'] : '' ); $cat_settings_on = ( !empty($wup_options['cat_settings_on']) ? $wup_options['cat_settings_on'] : '' ); if ($global_settings_on) { $global_upsell_enabled = ( !empty($wup_options['enable_upsell_global']) ? $wup_options['enable_upsell_global'] : '' ); if (!$global_upsell_enabled) $classes[] = 'wup-popup-disabled'; } else if ($cat_settings_on) { $new_cat_ids = array(); $cat_list_ids = wp_get_post_terms($product_id, 'product_cat', array('fields'=>'ids')); foreach ($cat_list_ids as $cat_list_id) { $cat_info = get_term_by('id', $cat_list_id, 'product_cat'); $cat_name = $cat_info->name; if ($cat_info->parent) { $cat_list_id = $cat_info->parent; $parent_info = get_term_by('id', $cat_list_id, 'product_cat'); $cat_name = $parent_info->name; } $new_cat_ids[$cat_list_id] = $cat_name; } asort($new_cat_ids); reset($new_cat_ids); $cat_id = key($new_cat_ids); //first category ID $cat_upsell_enabled = ( !empty($wup_options['enable_upsell_cat'.$cat_id]) ? $wup_options['enable_upsell_cat'.$cat_id] : '' ); if (!$cat_upsell_enabled) $classes[] = 'wup-popup-disabled'; } else { $single_upsell_enabled = get_post_meta($product_id, 'thp_wc_enable_upsell_on_single_product', true); if (!$single_upsell_enabled) $classes[] = 'wup-popup-disabled'; } } return $classes; } add_filter( 'body_class','thp_wup_popup_add_class' );
And then enqueue the following javascript code on Woocommerce product pages, or you could use plugins like Simple Custom CSS and JS to add this custom js code to your site.
jQuery(document).ready(function(){ jQuery(document).on('added_to_cart', function() { if (jQuery("body").hasClass("wup-popup-disabled")) { window.location.replace("/cart"); } }); });
Code tested and works. In LINE 4 above, you could hard code your site’s cart URL if it doesn’t work.
Hope this solves the problem!
If you look at the description of the plugin here on www.ads-software.com, under Woocommerce Settings, it says:
For the plugin to work as intended, set the Woocommerce setting as follows:
Go to Woocommerce > Settings > Products > General > Shop pages.
And then for ‘Add to cart behaviour’, uncheck ‘Redirect to the cart page after successful addition’.
That’s how the plugin works out of the box.
You could use WordPress hooks or some javascript/jquery to change this behavior if you want. Hang on, I’ll come up with something.