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( 'woocommerce_package_rates','overwrite_shipping_cost', 100, 2 ); | |
| function overwrite_shipping_cost($rates, $package ) { | |
| global $woocommerce; | |
| if ( get_field( 'multiplier', 'option' ) ) : | |
| $multiplier = get_field( 'multiplier', 'option' ); | |
| else : | |
| $multiplier = 1; |
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 | |
| /* | |
| * Automatically adding gift product to the cart | |
| * Click on Add to Cart of Product A(under category cricket bat) will automatically add Gift A to cart | |
| * Click on Add to Cart of Product B(under category cricket bat) will automatically add Gift A to cart | |
| * Click on Add to Cart of Gift A will not automatically add Gift A to cart | |
| */ | |
| function aaptc_add_product_to_cart( $item_key, $product_id ) { |
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 | |
| /* | |
| * Automatically adding multiple products to the cart based on the multiple categories. | |
| */ | |
| function aaptc_add_product_to_cart( $item_key, $product_id ) { | |
| $product_category_id = array( 17, 18 ); // Category ids Hoodies & T-Shirts | |
| $product_cats_ids = wc_get_product_term_ids( $product_id, 'product_cat' ); // Getting assigned categories of product which is being added to cart |
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 | |
| /** | |
| * Product quantity inputs | |
| * | |
| * This template can be overridden by copying it to yourtheme/woocommerce/global/quantity-input.php. | |
| * | |
| * HOWEVER, on occasion WooCommerce will need to update template files and you | |
| * (the theme developer) will need to copy the new files to your theme to | |
| * maintain compatibility. We try to do this as little as possible, but it does | |
| * happen. When this occurs the version of the template file will be bumped and |
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 | |
| function wcget_category_ids(){ | |
| $orderby = 'name'; | |
| $order = 'asc'; | |
| $hide_empty = false ; | |
| $cat_args = array( | |
| 'orderby' => $orderby, | |
| 'order' => $order, |
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 | |
| /** | |
| * Removing free product from cart when cart doensn't contains product of perticular category. | |
| */ | |
| function remove_product_from_cart() { | |
| // Run only in the Cart or Checkout Page | |
| if ( is_cart() || is_checkout() ) { |
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 | |
| function exclude_product_of_specific_category( $q ) { | |
| if ( is_shop() ) { | |
| $tax_query = (array) $q->get( 'tax_query' ); | |
| $tax_query[] = array( | |
| 'taxonomy' => 'product_cat', | |
| 'field' => 'slug', |
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 | |
| /* | |
| * Automatically adding the product to the cart when cart total amount reach to $500. | |
| * Also, when customer removes the free product from cart then do not add free product again to cart automatically. | |
| */ | |
| function aapc_add_product_to_cart() { | |
| global $woocommerce; | |
| $free_product_id = 1514; // Product Id of the free product which will get added to cart | |
| $list_of_removed_product = array(); // In this we will add all the removed product ids |
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 | |
| /* | |
| * Automatically adding the product to the cart when cart total amount reach to $500 and number of produc added in cart is 3 or more. | |
| */ | |
| function aapc_add_product_to_cart() { | |
| global $woocommerce; | |
| $cart_total = 500; | |
| $number_of_product = 3; | |
| $number_of_product_in_cart = WC()->cart->get_cart_contents_count(); // Number of products in cart. |
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 | |
| /* | |
| * Automatically adding the product to the cart for only specific user roles. | |
| */ | |
| function aaptc_add_product_to_cart( $item_key, $product_id ) { | |
| $product_category_id = 123; // cricket bat category id | |
| $product_cats_ids = wc_get_product_term_ids( $product_id, 'product_cat' ); | |
| $user = wp_get_current_user(); // This will fetch current user's role | |
| $allowed_roles = array( 'booking_agent', 'perfecth' ); // These are the list of allowed user role. |