Comments on: Moving the WooCommerce cart icon from the secondary menu to the primary menu in the Divi theme https://diviengine.com/moving-woocommerce-cart-icon-to-primary-menu-in-the-divi-theme/ Boost the power of your Divi website Fri, 17 Nov 2023 12:30:39 +0000 hourly 1 https://wordpress.org/?v=6.5.4 By: irene https://diviengine.com/moving-woocommerce-cart-icon-to-primary-menu-in-the-divi-theme/#comment-190770 Tue, 15 Mar 2022 01:48:10 +0000 https://diviengine.com/?p=10432#comment-190770 Hi there! thanks so much for the hard work. I have tried your solution but it is not working on our site. I see the last post was December 21, could you please let me know if anything has changed since then that’s stopping this from working? Thank you in advance

]]>
By: Adam https://diviengine.com/moving-woocommerce-cart-icon-to-primary-menu-in-the-divi-theme/#comment-184031 Sat, 04 Dec 2021 19:05:36 +0000 https://diviengine.com/?p=10432#comment-184031 I have been looking for some time now and I would like to know the best way to simply have my Cart icon link directly to checkout and not to cart. Anybody can help?

]]>
By: Divi Engine https://diviengine.com/moving-woocommerce-cart-icon-to-primary-menu-in-the-divi-theme/#comment-149427 Tue, 22 Sep 2020 08:06:59 +0000 https://diviengine.com/?p=10432#comment-149427 In reply to bluebeautifly.

We will look to do this – but I am sure you can use the theme builder now to do this?

ET = Elegant Themes 😀

]]>
By: bluebeautifly https://diviengine.com/moving-woocommerce-cart-icon-to-primary-menu-in-the-divi-theme/#comment-149406 Mon, 21 Sep 2020 21:40:55 +0000 https://diviengine.com/?p=10432#comment-149406 In reply to Divi Engine.

We would love to have a solution to move the Cart to the right of the Search icon as it is more intuitive to Search first (on the left) and then Buy (on the right). Who is ET?

]]>
By: Divi Engine https://diviengine.com/moving-woocommerce-cart-icon-to-primary-menu-in-the-divi-theme/#comment-146920 Mon, 24 Aug 2020 09:38:18 +0000 https://diviengine.com/?p=10432#comment-146920 In reply to Jyde.

Haven’t looked at this to be honest. Have you contacted ET about this?

]]>
By: Jyde https://diviengine.com/moving-woocommerce-cart-icon-to-primary-menu-in-the-divi-theme/#comment-146824 Sun, 23 Aug 2020 00:18:23 +0000 https://diviengine.com/?p=10432#comment-146824 Hello,

The cart icon on my divi is positioned to the left, how do I please change the position to right?

]]>
By: Divi Engine https://diviengine.com/moving-woocommerce-cart-icon-to-primary-menu-in-the-divi-theme/#comment-143729 Tue, 21 Jul 2020 07:05:36 +0000 https://diviengine.com/?p=10432#comment-143729 In reply to Diyafury.

Thanks for this – It is 100% a great way to do it!

]]>
By: Diyafury https://diviengine.com/moving-woocommerce-cart-icon-to-primary-menu-in-the-divi-theme/#comment-143681 Mon, 20 Jul 2020 18:12:16 +0000 https://diviengine.com/?p=10432#comment-143681 Another way without creating a new file is to overwrite the divi et_show_cart_total function in the divi theme functions.php with your modified function in your child theme’s functions.php (I added an additional css class, removed the word items and made sure that no_text is always false to show the count):

// Overwrite Divi cart icon display for primary menu to include cart count
if ( ! function_exists( ‘et_show_cart_total’ ) ) {
function et_show_cart_total( $args = array() ) {
if ( ! class_exists( ‘woocommerce’ ) || ! WC()->cart ) {
return;
}

$defaults = array(
‘no_text’ => false,
);

$args = wp_parse_args( $args, $defaults );

$items_number = WC()->cart->get_cart_contents_count();

$url = function_exists( ‘wc_get_cart_url’ ) ? wc_get_cart_url() : WC()->cart->get_cart_url();

//Modification
$class = ( $items_number > 0 ) ? ‘ not-empty’ : ‘ empty’;
$args[‘no_text’] = false;
//

printf(

%2$s
‘,
esc_url( $url ),
( ! $args[‘no_text’]
? esc_html( sprintf(
_nx( ‘%1$s’, ‘%1$s’, $items_number, ‘WooCommerce items number’, ‘Divi’ ),
number_format_i18n( $items_number )
) )
: ”
),
$class
);
}
}

]]>
By: Divi Engine https://diviengine.com/moving-woocommerce-cart-icon-to-primary-menu-in-the-divi-theme/#comment-143619 Mon, 20 Jul 2020 08:51:31 +0000 https://diviengine.com/?p=10432#comment-143619 In reply to Bryan Young.

You can do this using our plugin Divi BodyCommerce: https://diviengine.com/product/divi-bodycommerce/

]]>
By: Bryan Young https://diviengine.com/moving-woocommerce-cart-icon-to-primary-menu-in-the-divi-theme/#comment-143591 Mon, 20 Jul 2020 03:38:48 +0000 https://diviengine.com/?p=10432#comment-143591 Is there a way of having the cart only show the icon and number but not the text “items”?
The extra space taken up by the word “items” causes layout issues on mobile.

Thank you, Bryan

]]>
By: Divi Engine https://diviengine.com/moving-woocommerce-cart-icon-to-primary-menu-in-the-divi-theme/#comment-140722 Thu, 02 Jul 2020 06:40:03 +0000 https://diviengine.com/?p=10432#comment-140722 In reply to Zeshan.

Perfect, thanks for letting us know!

]]>
By: Zeshan https://diviengine.com/moving-woocommerce-cart-icon-to-primary-menu-in-the-divi-theme/#comment-140713 Thu, 02 Jul 2020 04:51:21 +0000 https://diviengine.com/?p=10432#comment-140713 Worked Perfectly. Thanks

]]>
By: Divi Engine https://diviengine.com/moving-woocommerce-cart-icon-to-primary-menu-in-the-divi-theme/#comment-140280 Wed, 01 Jul 2020 08:04:05 +0000 https://diviengine.com/?p=10432#comment-140280 In reply to Jason.

Brilliant – thanks for the feedback!

]]>
By: Jason https://diviengine.com/moving-woocommerce-cart-icon-to-primary-menu-in-the-divi-theme/#comment-140260 Wed, 01 Jul 2020 04:57:53 +0000 https://diviengine.com/?p=10432#comment-140260 Worked for me, thanks.

]]>
By: Divi Engine https://diviengine.com/moving-woocommerce-cart-icon-to-primary-menu-in-the-divi-theme/#comment-140079 Mon, 29 Jun 2020 08:03:50 +0000 https://diviengine.com/?p=10432#comment-140079 In reply to Zaqir.

Not sure, please send me a URL so I can see?

]]>
By: Zaqir https://diviengine.com/moving-woocommerce-cart-icon-to-primary-menu-in-the-divi-theme/#comment-140042 Sun, 28 Jun 2020 15:09:54 +0000 https://diviengine.com/?p=10432#comment-140042 Hi,

Thanks for this! One little problem though, I am using the child theme you added and the cart icon is showing on the further left of the menu after adding the child theme and activating it, I am using the “Centered Inline Menu” settings.

Any ideas?

]]>
By: Divi Engine https://diviengine.com/moving-woocommerce-cart-icon-to-primary-menu-in-the-divi-theme/#comment-137772 Mon, 01 Jun 2020 11:16:15 +0000 https://diviengine.com/?p=10432#comment-137772 In reply to Andres.

Yeah sorry we have not updated the tutorial for the new header.php file but it would be the same.

Not sure why it would not work on the other pages, are you using the theme builder on these?

Why not use the Theme Builder to create the header for all pages and then you can use the menu module and enable the cart icon where you want it?

]]>
By: Andres https://diviengine.com/moving-woocommerce-cart-icon-to-primary-menu-in-the-divi-theme/#comment-137716 Sun, 31 May 2020 09:21:51 +0000 https://diviengine.com/?p=10432#comment-137716 Hello, it doesn’t work, and yes i made all the steps, i have a child theme and yes i have the header.php, something is wrong with the code because it works fine in the shop page, but when i go to other pages it just goes back to the secondary menu. It will be nice if you found the problem. Also mention that for the new version of divi and woocommerce there is more lines in the header.

thanks

]]>
By: Divi Engine https://diviengine.com/moving-woocommerce-cart-icon-to-primary-menu-in-the-divi-theme/#comment-137338 Tue, 26 May 2020 06:21:36 +0000 https://diviengine.com/?p=10432#comment-137338 In reply to Brooke.

Maybe re-do it by copying the header.php file of the new Divi – maybe there is something there making it not work (I have not had time to replicate this, sorry)

]]>
By: Brooke https://diviengine.com/moving-woocommerce-cart-icon-to-primary-menu-in-the-divi-theme/#comment-137336 Tue, 26 May 2020 00:17:59 +0000 https://diviengine.com/?p=10432#comment-137336 In reply to Divi Engine.

Hi,

That is correct. I had this functioning well until recent upgrades. Using standard Divi Header.

]]>
By: Divi Engine https://diviengine.com/moving-woocommerce-cart-icon-to-primary-menu-in-the-divi-theme/#comment-137220 Mon, 25 May 2020 06:57:22 +0000 https://diviengine.com/?p=10432#comment-137220 In reply to Brooke.

So was it working and then you updated Divi and now it does not? Are you using a custom header?

]]>
By: Brooke https://diviengine.com/moving-woocommerce-cart-icon-to-primary-menu-in-the-divi-theme/#comment-137203 Mon, 25 May 2020 02:50:11 +0000 https://diviengine.com/?p=10432#comment-137203 In reply to Divi Engine.

Hi,

This seemed to be working prior to updating Divi. Are you able to let me know what the issue might be for my theme please?

]]>
By: Divi Engine https://diviengine.com/moving-woocommerce-cart-icon-to-primary-menu-in-the-divi-theme/#comment-127442 Mon, 06 Apr 2020 09:44:51 +0000 https://diviengine.com/?p=10432#comment-127442 In reply to Binks.

Glad it helped you. Have a great week!

]]>
By: Binks https://diviengine.com/moving-woocommerce-cart-icon-to-primary-menu-in-the-divi-theme/#comment-127379 Sun, 05 Apr 2020 21:58:27 +0000 https://diviengine.com/?p=10432#comment-127379 Thanks, worked! Using Divi 3 builder.

]]>
By: Divi Engine https://diviengine.com/moving-woocommerce-cart-icon-to-primary-menu-in-the-divi-theme/#comment-117538 Tue, 18 Feb 2020 07:17:58 +0000 https://diviengine.com/?p=10432#comment-117538 In reply to caleb.

Sounds silly, but do you have the child theme active? Did you edit the header.php file in your child theme?

]]>
By: caleb https://diviengine.com/moving-woocommerce-cart-icon-to-primary-menu-in-the-divi-theme/#comment-117505 Mon, 17 Feb 2020 18:43:14 +0000 https://diviengine.com/?p=10432#comment-117505 didn’t work for me either . Did all the steps and cart is still in the secondary menu

]]>
By: Divi Engine https://diviengine.com/moving-woocommerce-cart-icon-to-primary-menu-in-the-divi-theme/#comment-106190 Fri, 13 Dec 2019 12:29:45 +0000 https://diviengine.com/?p=10432#comment-106190 In reply to MaximePotier.

It shouldn’t change unless you are using the theme builder to design your header. If you are using this, Divi ignore the header.php file so it wont work.

If you are using the default Divi header, it should be fine.

]]>
By: MaximePotier https://diviengine.com/moving-woocommerce-cart-icon-to-primary-menu-in-the-divi-theme/#comment-106186 Fri, 13 Dec 2019 11:53:08 +0000 https://diviengine.com/?p=10432#comment-106186 Hi Pete
It seems it doesn’t work anymore with Divi 4 Theme Builder
Cart Icon goes back to the secondary menu 🙁
Did you notice that?

]]>
By: Divi Engine https://diviengine.com/moving-woocommerce-cart-icon-to-primary-menu-in-the-divi-theme/#comment-94371 Thu, 07 Nov 2019 08:45:41 +0000 https://diviengine.com/?p=10432#comment-94371 In reply to jorge.

Change the code to be: et_show_cart_total(); – this should show the totals

]]>
By: jorge https://diviengine.com/moving-woocommerce-cart-icon-to-primary-menu-in-the-divi-theme/#comment-94054 Mon, 04 Nov 2019 18:11:55 +0000 https://diviengine.com/?p=10432#comment-94054 Thanks for tuhe tutorial. I´ve done it but it only shows the icon but no quantity of elements like when it is in secondary menu. Do you know why? Thanks in advantage.

]]>
By: Divi Engine https://diviengine.com/moving-woocommerce-cart-icon-to-primary-menu-in-the-divi-theme/#comment-75328 Wed, 04 Sep 2019 15:42:27 +0000 https://diviengine.com/?p=10432#comment-75328 In reply to Shahrooz.

Thanks for the comment. Is the code for the cart added to your header.php file?

]]>
By: Shahrooz https://diviengine.com/moving-woocommerce-cart-icon-to-primary-menu-in-the-divi-theme/#comment-75069 Tue, 03 Sep 2019 16:51:47 +0000 https://diviengine.com/?p=10432#comment-75069 Hi,

Thanks for the solution but it didn’t work on my side. I’ve used the header.php from the provided child theme but no cart icon on main menu.

Any clue?

Thanks,

]]>
By: Divi Engine https://diviengine.com/moving-woocommerce-cart-icon-to-primary-menu-in-the-divi-theme/#comment-26531 Thu, 14 Feb 2019 14:17:32 +0000 https://diviengine.com/?p=10432#comment-26531 In reply to ZUOO.

Not sure – I just checked and it is working for me. Can you try download this child theme to check (https://diviengine.com/wp-content/uploads/2019/01/divi-child-theme-cart.zip)?

If you have issues after this try shooting an email to su*****@di********.com with your URL and I will take a look

]]>
By: ZUOO https://diviengine.com/moving-woocommerce-cart-icon-to-primary-menu-in-the-divi-theme/#comment-26530 Thu, 14 Feb 2019 13:49:28 +0000 https://diviengine.com/?p=10432#comment-26530 Hey,

When i do this, the mobile menu completely disappears. I think it has something to do with lines 289-291 but as soon as i remove the if statement around 284 it doesn’t inject the mobile menu in the html.

Any idea why?

]]>