Created
September 11, 2017 06:14
-
-
Save kreamweb/428af31704cbaf96a3e9969a27d366d1 to your computer and use it in GitHub Desktop.
Calculate total only of shipping products
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_filter('ywcm_cart_total','ywcm_cart_total'); | |
| function ywcm_cart_total( $total ){ | |
| $total = 0; | |
| if ( ! empty( WC()->cart->cart_contents ) ) { | |
| foreach ( WC()->cart->cart_contents as $cart_item_key => $values ) { | |
| if ( $values['data']->needs_shipping() ) { | |
| $total += $values['line_total']; | |
| } | |
| } | |
| } | |
| return $total; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment