Changeset 2857355
- Timestamp:
- 01/30/2023 10:05:49 PM (3 years ago)
- Location:
- disable-coupons-at-product-level
- Files:
-
- 5 added
- 2 edited
-
tags/1.0.1 (added)
-
tags/1.0.1/css (added)
-
tags/1.0.1/css/admin.css (added)
-
tags/1.0.1/disable-coupons.php (added)
-
tags/1.0.1/readme.txt (added)
-
trunk/disable-coupons.php (modified) (4 diffs)
-
trunk/readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
disable-coupons-at-product-level/trunk/disable-coupons.php
r2856693 r2857355 3 3 * Plugin Name: Disable Coupons At Product Level 4 4 * Description: A plugin to disable coupons on selected products 5 * Version: 1.0 5 * Version: 1.0.1 6 6 * Author: Phil Clerkin 7 7 * Author URI: https://greyphox.com/ … … 26 26 27 27 28 add_action( 'woocommerce_product_data_panels', 'DCAPL_add_custom_field_ general_product_fields' );29 function DCAPL_add_custom_field_ general_product_fields(){28 add_action( 'woocommerce_product_data_panels', 'DCAPL_add_custom_field_General_product_fields' ); 29 function DCAPL_add_custom_field_General_product_fields(){ 30 30 global $post; 31 31 $disable_coupons = get_post_meta( $post->ID, 'DCAPL_disable_coupons', true ); 32 32 echo '<div id="DCAPL_product_data" class="panel woocommerce_options_panel">'; 33 34 // Custom Product Checkbox Field Info35 33 woocommerce_wp_checkbox( array( 36 34 'id' => '_disable_coupons', … … 38 36 'description' => __('If checked discounts will not be applied to this product via the use of coupons', 'woocommerce'), 39 37 'desc_tip' => 'true', 38 'value' => $disable_coupons == 'yes' ? 'yes' : 'no' 40 39 ) ); 41 40 echo '</div>'; 42 41 } 42 43 43 44 44 45 … … 69 70 add_filter( 'woocommerce_coupon_get_discount_amount', 'DCAPL_zero_discount_for_excluded_products', 12, 5 ); 70 71 function DCAPL_zero_discount_for_excluded_products($discount, $discounting_amount, $cart_item, $single, $coupon ){ 71 $disabled_products = get_option( 'DCAPL_ _products_disable_coupons' );72 $disabled_products = get_option( 'DCAPL_products_disable_coupons' ); 72 73 $discount = count( $disabled_products ) > 0 && in_array( $cart_item['product_id'], $disabled_products ) ? 0 : $discount; 73 74 return $discount; -
disable-coupons-at-product-level/trunk/readme.txt
r2856699 r2857355 7 7 License: GPLv2 or later 8 8 License URI: [http://www.gnu.org/licenses/gpl-2.0.html](http://www.gnu.org/licenses/gpl-2.0.html) 9 Stable tag: 1.0 9 Stable tag: 1.0.1 10 10 11 11 A Wordpress plugin that allows users to disable customers use of coupons on selected products in WooCommerce … … 27 27 1. View of options on product screen 28 28 29 30 == Changelog == 31 32 = 1.0.1 = 33 34 - Fixed: Checkbox field status not saving on product page
Note: See TracChangeset
for help on using the changeset viewer.