Here is how to to set up a main WooCommerce template, particularly how to set up a header.
The oxyelements WooCommerce header includes a Dynamic Cart icon that automatically updates a little number icon every time you add a new product to the cart.
For this, we will use a custom PHP script:
add_filter( 'woocommerce_add_to_cart_fragments', 'oe_cart_count_fragments', 1, 1 ); function oe_cart_count_fragments( $fragments ) { $fragments['div.header-cart-count'] = '<div class="header-cart-count" data-cart-count="' . WC()->cart->get_cart_contents_count() . '">' . WC()->cart->get_cart_contents_count() . '</div>'; return $fragments; }
You can install using a plugin called Code Snippets or using your own function.php file if you prefer.
With this out of the way, we have to create a main template.
Inside Oxygen Builder, with the new main template loaded, you can load our main template.
If you save and go to the frontend, you should already see the header with the cart button and dynamic number, which will automatically update based on this script we inserted earlier.
In the Structure panel, you'll find some features that we have already inserted. These you can customize as you want.
For example, we have a custom implementation of the Search Feature, where we have put an icon inside the search field and made it search for products instead of only posts, which is the default in WordPress.
With this set up, you just click save, and you'll be done with this tutorial.
Next step
How to setup Oxygen Builder global styles for WooCommerce
To learn more about