- This topic has 21 replies, 3 voices, and was last updated 7 years, 8 months ago by
Tom.
-
AuthorPosts
-
January 11, 2018 at 9:40 am #468535
Tom
Lead DeveloperLead DeveloperFirst thing you want to do is remove everything from your child theme functions.php file, your file should look like this:
<?php function custom_wc_cart_link() { ob_start(); ?> <a href="<?php echo esc_url( WC()->cart->get_cart_url() ); ?>" class="cart-contents" title="עגלה שלי"> <i class="fa fa-shopping-cart" aria-hidden="true"></i> <small><?php echo sprintf ( _n( '%d', '%d', WC()->cart->get_cart_contents_count() ), WC()->cart->get_cart_contents_count() ); ?></small> </a> <?php return ob_get_clean(); } function custom_wc_menu_cart( $nav, $args ) { if ( $args->theme_location == 'primary' && generatepress_wc_get_setting( 'cart_menu_item' ) ) { return sprintf( '%1$s <li class="wc-menu-item %4$s" title="%2$s"> %3$s </li>', $nav, esc_attr__( 'View your shopping cart','generate-woocommerce' ), custom_wc_cart_link(), is_cart() ? 'current-menu-item' : '' ); } // Our primary menu isn't set, return the regular nav return $nav; } add_action( 'after_setup_theme','remove_wc_cart_item' ); function remove_wc_cart_item() { remove_filter( 'wp_nav_menu_items','generatepress_wc_menu_cart', 10, 2 ); add_filter( 'wp_nav_menu_items','custom_wc_menu_cart', 10, 2 ); add_filter( 'woocommerce_add_to_cart_fragments', 'custom_wc_cart_link' ); }
January 11, 2018 at 10:20 am #468560Jacob
Hi Tom
Sorry but I do not understand .. What should I remove. And where it is found what needs to be removed.
Sorry for the ignorance and thank you for your patienceJanuary 11, 2018 at 8:27 pm #468909Tom
Lead DeveloperLead DeveloperInstead of using the functions.php file, use this plugin: https://en-ca.wordpress.org/plugins/code-snippets/
And add this code to a new snippet:
function custom_wc_cart_link() { ob_start(); ?> <a href="<?php echo esc_url( WC()->cart->get_cart_url() ); ?>" class="cart-contents" title="עגלה שלי"> <?php echo sprintf ( _n( '%d', '%d', WC()->cart->get_cart_contents_count() ), WC()->cart->get_cart_contents_count() ); ?> </a> <?php return ob_get_clean(); } function custom_wc_menu_cart( $nav, $args ) { if ( $args->theme_location == 'primary' && generatepress_wc_get_setting( 'cart_menu_item' ) ) { return sprintf( '%1$s <li class="wc-menu-item %4$s" title="%2$s"> %3$s </li>', $nav, esc_attr__( 'View your shopping cart','generate-woocommerce' ), custom_wc_cart_link(), is_cart() ? 'current-menu-item' : '' ); } // Our primary menu isn't set, return the regular nav return $nav; } add_action( 'after_setup_theme','remove_wc_cart_item' ); function remove_wc_cart_item() { remove_filter( 'wp_nav_menu_items','generatepress_wc_menu_cart', 10, 2 ); add_filter( 'wp_nav_menu_items','custom_wc_menu_cart', 10, 2 ); add_filter( 'woocommerce_add_to_cart_fragments', 'custom_wc_cart_link' ); }
January 12, 2018 at 3:20 pm #469668Jacob
Thanks Tom
It works perfect!
Now I just need a drop-down menu with an optional cart / checkout
And the products I added to my shopping cartThanks for the help
January 12, 2018 at 6:56 pm #469743Tom
Lead DeveloperLead DeveloperCurrently GP can’t do that by default, and the amount of code is too much for the forum.
We’re hoping to get it added to the WC module in GPP soon 🙂
January 13, 2018 at 2:24 am #469851Jacob
Thanks Tom.
I appreciate your help, and your patience.
I’m very glad I bought a template where the support is excellent.
Hopefully in the future will be this model.
Go up and succeedThanks Kobi
January 13, 2018 at 9:17 am #470087Tom
Lead DeveloperLead DeveloperThank you! 🙂
-
AuthorPosts
- You must be logged in to reply to this topic.