- This topic has 24 replies, 2 voices, and was last updated 2 years, 7 months ago by David.
-
AuthorPosts
-
February 24, 2018 at 1:04 pm #504733Michael
Hey guys – thanks for your continued support. I’m learning as I go.
Easy Digital Downloads has a code for Ajax enabled cart quantity updates. Currently, my site has a shopping cart icon in the navigation – I would like to add the quantity next to the cart as items are added (obviously). EDD has a code for this here –
https://docs.easydigitaldownloads.com/article/275-showing-the-cart-quantity-in-your-templates
I think I need to use hooks to achieve this? I’m running into a wall here as I’m not sure where to insert that code.
Thanks in advance for the help!
February 24, 2018 at 8:32 pm #504902TomLead DeveloperLead DeveloperHi there,
The easiest way would be to use this plugin: https://en-ca.wordpress.org/plugins/wp-menu-cart/
Otherwise you could try hooking it in:
add_action( 'generate_inside_navigation', 'tu_add_edd_cart_to_nav' ); function tu_add_edd_cart_to_nav() { if ( ! function_exists( 'edd_get_checkout_uri' ) ) { return; } ?> <a class="edd-cart" href="<?php echo edd_get_checkout_uri(); ?>"> Cart (<span class="header-cart edd-cart-quantity"><?php echo edd_get_cart_quantity(); ?></span>) </a> <?php }
February 25, 2018 at 11:36 pm #505662MichaelThank you! Will see how the plugin works. If I was to hook it in, would I paste code that in the GP Hooks section of the plugin? And if so, which one? I thought there might be a generate_inside_navigation within the GP Hooks section but I don’t see one.
Thanks again!
February 26, 2018 at 8:29 am #506053LeoStaffCustomer SupportThat hook is not included in the Hooks module (only the popular ones are included in there).
So try one of the methods here: https://docs.generatepress.com/article/adding-php/
Code Snippets is the easiest if you aren’t using a child theme.
February 28, 2018 at 11:11 am #508189MichaelThe plugin that you recommended Tom is excellent. If I can work out the kinks I think I will just use this.
I was able to use the hook provided (using code snippets) and create almost what I wanted, which was the shopping cart with the number of items in parenthesis. The trouble was getting the icon to center (heighth wise) as well as the styling of the number of items. Given my total newbness when it comes to this kind of thing, I think the plugin will do just fine.
Quick question – the plugin generates a cart with the number of items. I can align this to the left or right, however, when I align to the right (which is where I want it), it lists before the search icon. Preferably, the search icon is the first of my icons to display on the right, and the cart icon will be where my current cart icon is now. The link I provided in my first post should show this. The paid version allows custom CSS – will the menu-item-float-right send it past the search icon as it does with my other menu items that I float right? I hope I’m making sense…
Thanks again for the awesome support. Really happy I chose this theme.
Mike
February 28, 2018 at 11:24 pm #508566TomLead DeveloperLead DeveloperGive this CSS a shot:
.main-navigation li.search-item, .wpmenucart-display-right { float: none !important; display: inline-block; } #menu-navigation-bar { text-align: right; }
Let me know π
March 1, 2018 at 12:09 am #508595MichaelWorked perfectly. Thank you so much!
March 1, 2018 at 10:04 am #509046TomLead DeveloperLead DeveloperYou’re welcome π
July 31, 2018 at 2:28 am #636763OlivierHi Tom
Thank you for your code but I have a problem.
How to hide the cart and view the number of products in the Menu ?Thank you for your help
Olivier
[url=https://ibb.co/jQAZZT][img]https://preview.ibb.co/cqwmg8/Capture.png[/img][/url]
July 31, 2018 at 10:14 am #637129TomLead DeveloperLead DeveloperThat icon shouldn’t appear with my code above. Are you using this?: https://generatepress.com/forums/topic/edd-shopping-cart-quantity-in-navigation/#post-504902
July 31, 2018 at 10:26 am #637136OlivierHi Tom
Yes I have a test but nothing appears, the code does not change anything… it’s strange.I use a child theme with function.php.
Thank you for your help
July 31, 2018 at 4:57 pm #637363TomLead DeveloperLead DeveloperAny chance you can open a new support topic and include the URL to your website?
Thanks!
August 1, 2018 at 2:11 am #637551OlivierHi
I can open a new topic but without the URL because the website is inside a secure server for the development.I open a new topic with somes informations ?
Thank you
August 1, 2018 at 4:57 am #637656DavidStaffCustomer SupportHi Olivier,
Tom will need to see the site, if you raise a new topic you can add the URL to the Site URL field and only we can see that. If you need to send user login details you can use the Account Issue form here: https://generatepress.com/contact/ and provide a link to the topic.
August 1, 2018 at 5:50 am #637688OlivierHi David
OK nice π
A send a message
Thank you -
AuthorPosts
- You must be logged in to reply to this topic.