Skip to content

Instantly share code, notes, and snippets.

@xlplugins
Created April 23, 2025 11:15
Show Gist options
  • Save xlplugins/aceb5d68802a49efe99dff06f050463d to your computer and use it in GitHub Desktop.
Save xlplugins/aceb5d68802a49efe99dff06f050463d to your computer and use it in GitHub Desktop.
Enable 0 discounting on Regular Price
class WFACP_Enable_zero_discount {
private $item;
private $regular_price = 0;
public function __construct() {
add_filter( 'wfacp_allow_zero_discounting', [ $this, 'allow_zero_discount' ], 10, 2 );
add_filter( 'wfacp_discount_regular_price_data', [ $this, 'get_regular_price' ] );
add_filter( 'wfacp_discount_price_data', [ $this, 'set_regular_price' ] );
}
public function allow_zero_discount( $status, $item ) {
$this->item = $item;
return false;
}
public function get_regular_price( $regular_price ) {
$this->regular_price = $regular_price;
return $this->regular_price;
}
public function set_regular_price( $price ) {
$type = $this->item['_wfacp_options']['discount_type'];
$discount_amount = (float) $this->item['_wfacp_options']['discount_amount'];
if ( 0 == $discount_amount && in_array( $type, array( 'fixed_discount_reg', 'percent_discount_reg' ) ) ) {
$price = $this->regular_price;
}
return $price;
}
}
new WFACP_Enable_zero_discount();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment