J Cart Upsell and Cross-sell and Shoptimizer
-
Sorry, accidentally double-posted.
Hi, great plugin, really like it!The issue I have is that I’m using Shoptimizer theme. I want to use your cart instead of shoptimizer’s cart. As I understand I need to add “wc-j-upsellator-show-cart” class to shoptimizer’s cart but I don’t know how to do it.
Could you help, please?
Thank you.-
This topic was modified 3 years, 1 month ago by
jurgisxd.
-
This topic was modified 3 years, 1 month ago by
-
Here we are! So, to add that class to the theme icon you need to override a pluggable function of shoptimizer called “shoptimizer_cart_link”.
First, you need to have a child theme.
Then paste this code into your child theme functions.php filefunction shoptimizer_cart_link() { $shoptimizer_layout_woocommerce_enable_sidebar_cart = ''; $shoptimizer_layout_woocommerce_enable_sidebar_cart = shoptimizer_get_option( 'shoptimizer_layout_woocommerce_enable_sidebar_cart' ); $shoptimizer_layout_woocommerce_cart_icon = ''; $shoptimizer_layout_woocommerce_cart_icon = shoptimizer_get_option( 'shoptimizer_layout_woocommerce_cart_icon' ); if ( ! shoptimizer_woo_cart_available() ) { return; } ?> <div class="cart-click wc-j-upsellator-show-cart"> <?php if ( true === $shoptimizer_layout_woocommerce_enable_sidebar_cart ) { ?> <a class="cart-contents" href="#" title="<?php esc_attr_e( 'View your shopping cart', 'shoptimizer' ); ?>"> <?php } else { ?> <a class="cart-contents" href="<?php echo wc_get_cart_url(); ?>" title="<?php esc_attr_e( 'View your shopping cart', 'shoptimizer' ); ?>"> <?php } ?> <span class="amount"><?php echo wp_kses_post( WC()->cart->get_cart_subtotal() ); ?></span> <?php if ( 'basket' === $shoptimizer_layout_woocommerce_cart_icon ) { ?> <span class="count"><?php echo wp_kses_post( /* translators: cart count */ sprintf( _n( '%d', '%d', WC()->cart->get_cart_contents_count(), 'shoptimizer' ), WC()->cart->get_cart_contents_count() ) ); ?></span> <?php } ?> <?php if ( 'cart' === $shoptimizer_layout_woocommerce_cart_icon ) { ?> <span class="shoptimizer-cart-icon"> <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor"> <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 3h2l.4 2M7 13h10l4-8H5.4M7 13L5.4 5M7 13l-2.293 2.293c-.63.63-.184 1.707.707 1.707H17m0 0a2 2 0 100 4 2 2 0 000-4zm-8 2a2 2 0 11-4 0 2 2 0 014 0z" /> </svg><span class="mini-count"><?php echo wp_kses_data( /* translators: cart count */ sprintf( _n( '%d', '%d', WC()->cart->get_cart_contents_count(), 'shoptimizer' ), WC()->cart->get_cart_contents_count() ) ); ?></span></span> <?php } ?> <?php if ( 'bag' === $shoptimizer_layout_woocommerce_cart_icon ) { ?> <span class="shoptimizer-cart-icon"> <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor"> <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M16 11V7a4 4 0 00-8 0v4M5 9h14l1 12H4L5 9z" /> </svg><span class="mini-count"><?php echo wp_kses_data( /* translators: cart count */ sprintf( _n( '%d', '%d', WC()->cart->get_cart_contents_count(), 'shoptimizer' ), WC()->cart->get_cart_contents_count() ) ); ?></span></span> <?php } ?> </a> </div> <?php }Don’t be scared, it’s just a copy/paste of the original function with the needed class added to the created html div.
Hi,
Thank you for your answer. Currently your cart slides out but it also automatically redirects to domain.com/cart/.
I’ve added that code to the bottom of functions.php file.Another thing – I cannot find how to turn off J Cart Upsells cart icon on the bottom of the page, I’ve turned off
Can you give me the website url so I can check online?
Hi, yes.
URL: spalvotiziedai.ltTry to replace the code above with this:
function shoptimizer_cart_link() { $shoptimizer_layout_woocommerce_enable_sidebar_cart = ''; $shoptimizer_layout_woocommerce_enable_sidebar_cart = shoptimizer_get_option( 'shoptimizer_layout_woocommerce_enable_sidebar_cart' ); $shoptimizer_layout_woocommerce_cart_icon = ''; $shoptimizer_layout_woocommerce_cart_icon = shoptimizer_get_option( 'shoptimizer_layout_woocommerce_cart_icon' ); if ( ! shoptimizer_woo_cart_available() ) { return; } ?> <div class="cart-click wc-j-upsellator-show-cart"> <a class="cart-contents" href="#" title="<?php esc_attr_e( 'View your shopping cart', 'shoptimizer' ); ?>"> <span class="amount"><?php echo wp_kses_post( WC()->cart->get_cart_subtotal() ); ?></span> <?php if ( 'basket' === $shoptimizer_layout_woocommerce_cart_icon ) { ?> <span class="count"><?php echo wp_kses_post( /* translators: cart count */ sprintf( _n( '%d', '%d', WC()->cart->get_cart_contents_count(), 'shoptimizer' ), WC()->cart->get_cart_contents_count() ) ); ?></span> <?php } ?> <?php if ( 'cart' === $shoptimizer_layout_woocommerce_cart_icon ) { ?> <span class="shoptimizer-cart-icon"> <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor"> <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 3h2l.4 2M7 13h10l4-8H5.4M7 13L5.4 5M7 13l-2.293 2.293c-.63.63-.184 1.707.707 1.707H17m0 0a2 2 0 100 4 2 2 0 000-4zm-8 2a2 2 0 11-4 0 2 2 0 014 0z" /> </svg><span class="mini-count"><?php echo wp_kses_data( /* translators: cart count */ sprintf( _n( '%d', '%d', WC()->cart->get_cart_contents_count(), 'shoptimizer' ), WC()->cart->get_cart_contents_count() ) ); ?></span></span> <?php } ?> <?php if ( 'bag' === $shoptimizer_layout_woocommerce_cart_icon ) { ?> <span class="shoptimizer-cart-icon"> <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor"> <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M16 11V7a4 4 0 00-8 0v4M5 9h14l1 12H4L5 9z" /> </svg><span class="mini-count"><?php echo wp_kses_data( /* translators: cart count */ sprintf( _n( '%d', '%d', WC()->cart->get_cart_contents_count(), 'shoptimizer' ), WC()->cart->get_cart_contents_count() ) ); ?></span></span> <?php } ?> </a> </div> <?php }In the main option page of our plugin, have you set icon position as “hidden”?
I’ve added the code but it still redirects to /cart/.
I’ve tried to change “Open Cart Position” to Hidden or Left, but the cart icon is still on the bottom right of the page.
I’ve just checked and it works: no icon on the bottom right and clicking the icon on the header just opens the side cart. Maybe cache issues?
Hm, I’ve cleared cache and also tried through other browsers but the bottom icon still exists and the top icon redirects to /cart/
Checked again, it’s for sure a cache issue. Inspecting code it’s like your changes are not reflected. Maybe server (hosting) level cache?
Server doesn’t have cache, I’ve removed site’s caching plugin, cleared cache in the site and in the browser but the issue still exists.
here’s the video of it redirecting https://youtu.be/9ciwlPTMLsg
I’m pretty sure it’s all about cache.
https://webm.red/wGYQ
That’s the video did few minutes ago :\Interesting, I’ve deleted the caching plugin and now it works like a charm.
Thank you!
Nice 🙂 I think you can reinstall it now, the cached pages should be gone!
Hi again, I don’t know where the issue exactly is, but:
When WP-Rocket is installed and the cart is empty, it automatically redirects to /cart/.
When WP-Rocket is installed and there are some product in the cart, the cart functions normally.
When WP-Rocket is not installed, the cart functions normally.Hello, have you tried the last plugin version? Also with the wp rocket integration active?
The topic ‘J Cart Upsell and Cross-sell and Shoptimizer’ is closed to new replies.