Forked from manospsyx/woocommerce-composites-hide-cart-order-components.php
Created
January 24, 2017 10:56
-
-
Save danilinked/6d45a6f1a892fcb447b5e7ddae8ed98c to your computer and use it in GitHub Desktop.
Use this snippet to hide Components in the cart, checkout, order and e-mail templates
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 | |
| /** | |
| * Plugin Name: WooCommerce Composite Products - Hide Components in all Templates | |
| * Plugin URI: http://www.woothemes.com/products/composite-products/ | |
| * Description: Use this snippet to hide Components in the cart, checkout, order and e-mail templates. | |
| * Version: 1.0 | |
| * Author: SomewhereWarm | |
| * Author URI: http://www.somewherewarm.net/ | |
| * Developer: Manos Psychogyiopoulos | |
| * | |
| * Requires at least: 3.8 | |
| * Tested up to: 4.2 | |
| * | |
| * Copyright: © 2015 Manos Psychogyiopoulos (psyx@somewherewarm.net). | |
| * License: GNU General Public License v3.0 | |
| * License URI: http://www.gnu.org/licenses/gpl-3.0.html | |
| */ | |
| // To use this snippet, download this file into your plugins directory and activate it, or copy the code under this line into the functions.php file of your (child) theme. | |
| add_filter( 'woocommerce_order_item_visible', 'wc_cp_order_item_visible', 10, 2 ); | |
| add_filter( 'woocommerce_widget_cart_item_visible', 'wc_cp_cart_item_visible', 10, 3 ); | |
| add_filter( 'woocommerce_cart_item_visible', 'wc_cp_cart_item_visible' , 10, 3 ); | |
| add_filter( 'woocommerce_checkout_cart_item_visible', 'wc_cp_cart_item_visible', 10, 3 ); | |
| /** Visibility of components in orders. | |
| * | |
| * @param boolean $visible | |
| * @param array $order_item | |
| * @return boolean | |
| */ | |
| function wc_cp_order_item_visible( $visible, $order_item ) { | |
| if ( ! empty( $order_item[ 'composite_parent' ] ) ) { | |
| $visible = false; | |
| } | |
| return $visible; | |
| } | |
| /** | |
| * Visibility of components in cart. | |
| * | |
| * @param boolean $visible | |
| * @param array $cart_item | |
| * @param string $cart_item_key | |
| * @return boolean | |
| */ | |
| function wc_cp_cart_item_visible( $visible, $cart_item, $cart_item_key ) { | |
| if ( ! empty( $cart_item[ 'composite_parent' ] ) ) { | |
| $visible = false; | |
| } | |
| return $visible; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment