|
| 1 | +<?xml version="1.0" encoding="UTF-8"?> |
| 2 | +<!-- This is a code snippets export file generated by the Code Snippets WordPress plugin. --> |
| 3 | +<!-- https://wordpress.org/plugins/code-snippets --> |
| 4 | +<!-- To import these snippets a WordPress site follow these steps: --> |
| 5 | +<!-- 1. Log in to that site as an administrator. --> |
| 6 | +<!-- 2. Install the Code Snippets plugin using the directions provided at the above link. --> |
| 7 | +<!-- 3. Go to 'Tools: Import' in the WordPress admin panel. --> |
| 8 | +<!-- 4. Click on the "Code Snippets" importer in the list --> |
| 9 | +<!-- 5. Upload this file using the form provided on that page. --> |
| 10 | +<!-- 6. Code Snippets will then import all of the snippets and associated information contained in this file into your site. --> |
| 11 | +<!-- 7. You will then have to visit the 'Snippets: All Snippets' admin menu and activate desired snippets. --> |
| 12 | +<!-- generator="Code Snippets/2.9.4" created="2017-11-08 16:15" --> |
| 13 | +<snippets> |
| 14 | + <snippet scope="2"> |
| 15 | + <name>Show a notice throughout the store if the cart is empty in WooCommerce</name> |
| 16 | + <desc></desc> |
| 17 | + <tags>empty, cart, notice</tags> |
| 18 | + <code>function wc_empty_cart_notice() { |
| 19 | + |
| 20 | + if ( WC()->cart->get_cart_contents_count() == 0 ) { |
| 21 | + wc_print_notice( __( 'Get free shipping if your order is over &#36;60!', 'woocommerce' ), 'notice' ); |
| 22 | + // Change notice text as desired |
| 23 | + } |
| 24 | + |
| 25 | +} |
| 26 | +// Add to cart page |
| 27 | +add_action( 'woocommerce_check_cart_items', 'wc_empty_cart_notice' ); |
| 28 | +// Add to shop archives & product pages |
| 29 | +add_action( 'woocommerce_before_main_content', 'wc_empty_cart_notice' );</code> |
| 30 | + </snippet> |
| 31 | +</snippets> |
0 commit comments