Home › Forums › Support › Point the shopping cart icon in the header to a shortcode instead of the cart
- This topic has 9 replies, 5 voices, and was last updated 1 year, 9 months ago by David.
-
AuthorPosts
-
October 28, 2021 at 12:31 pm #1981191wickedonline
Hi,
We are using a slider cart and they have provided us with a short code to point the cart button to. How can we change the destination of the cart so it can point to the slider cart?
I’ve tried this code, I just need to be able to insert the short code where it says http://www.google.com
add_filter( ‘woocommerce_get_cart_url’, ‘tu_custom_cart_url’ );
function tu_custom_cart_url() {
return ‘www.google.com’;
}This is the short code we want to call:
[checkoutwc_cart]October 28, 2021 at 12:55 pm #1981225YingStaffCustomer SupportHi there,
Not sure what are you trying to achieve, this php snippet can only change the URL of cart.
Can you tell me what exactly you want to achieve?
And can you also show me what content does this shortcode present? You can do it by insert in a page and link us to the page so we can have a rough idea.
Let me know ๐
October 28, 2021 at 1:50 pm #1981308wickedonlineI would like for when you click the cart icon up top to point here:
[checkoutwc_cart]
If you add something to cart it will show what we are trying to display when you click the cart icon up top.
October 28, 2021 at 6:09 pm #1981515ElvinStaffCustomer SupportHi there,
Filtering the cart’s URL will only change the URL of the link of the cart icon. It won’t do anything else.
If you’re expecting a popup to show up from that shortcode when you filter the URL then that’s not what’s going to happen.
Can you explain a bit more on your expected behavior?
October 28, 2021 at 6:20 pm #1981526wickedonlineI would like to open the slide out cart when you click the cart icon. I don’t want it to go to the cart page. I have included a link to a product so you can click the add to cart button and see the slide out cart. Thanks
October 28, 2021 at 6:36 pm #1981534ElvinStaffCustomer SupportIf that’s the case then what you need is to remove the default cart icon and then create a Hook Element to add the shortcode in.
To remove the cart icon, go to Appearance > GeneratePress and active the WooCommerce module.
Once activated, go to Appearnce > Customize > Layout > WooCommerce and uncheck “Display cart in menu”. This should remove the default cart icon.
You then add the shortcode through a Hook element. You can create a Hook element on Appearance > Elements if you have Elements module enabled on Appearance > GeneratePress.
On the Hook Element’s code area, add
[checkoutwc_cart]
.You then set the hook to
generate_menu_bar_items
and set the display rule location to entire site. You’ll also have to check the “Execute shortcode” checkbox and save the Hook Element.This should add the shortcode inplace of the cart icon. ๐
July 21, 2022 at 3:12 am #2289331SamHave you removed the hook location
generate_menu_bar_items
?I just tried this and it is not in the drop down menu. I then tried to set a custom hook as generate_menu_bar_items but it did not work.
Thanks
SamJuly 21, 2022 at 3:15 am #2289336DavidStaffCustomer SupportHi there,
in Customizer > General – is there an option to change the structure from Floats to Flexbox ?
If so, it needs to be on flexbox for that hook to be accessible.July 21, 2022 at 3:25 am #2289344SamYeah, I noticed that just after I sent that message. We never switched through fear of breaking things.
I tested it on our staging site and…
It messes with my display a little bit. Is it expected that the font-weight would change when you switch to flexbox?
July 21, 2022 at 3:28 am #2289347DavidStaffCustomer SupportHmmm… it shouldn’t mess with any typography settings.
If you want to start a new topic, where you can use the Private Information field to share a link to URL i cant take a look? -
AuthorPosts
- You must be logged in to reply to this topic.