Created
September 14, 2022 12:20
-
-
Save pramodjodhani/ae6f7923fff64b3eeec6beece6c4f594 to your computer and use it in GitHub Desktop.
Flux checkout - show notice "Get 20% off when purchasing 2"
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| add_action( 'woocommerce_review_order_before_cart_contents', 'flux_display_display_notice_to_get_discount_with_qty', 10 ); | |
| function flux_display_display_notice_to_get_discount_with_qty() { | |
| $current = WC()->cart->cart_contents_count; | |
| $return_to = wc_get_page_permalink( 'shop' ); | |
| echo '<tr><td colspan="2">'; | |
| switch ( $current ) { | |
| case '1': | |
| $added_text = 'Get 20% off when purchasing 2!'; | |
| $notice = sprintf( '<a href="%s" class="button wc-forward">%s</a> %s', esc_url( $return_to ), '', $added_text ); | |
| wc_print_notice( $notice, 'notice' ); | |
| break; | |
| case '2': | |
| $added_text = 'Get 30% off when purchasing 3!'; | |
| $notice = sprintf( '<a href="%s" class="button wc-forward">%s</a> %s', esc_url( $return_to ), '', $added_text ); | |
| wc_print_notice( $notice, 'notice' ); | |
| break; | |
| } | |
| echo '</td></tr>'; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment