Description
Do something after product prices have been updated.
Usage
gform.addAction( 'gpcp_after_update_pricing', function( triggerFieldId, GWConditionalPricing ) {
// do something crazy!
} );
Parameters
triggerFieldId int
The ID of the field that has triggered the pricing update.
GWConditionalPricing object
Current GWConditionalPricing object.
Examples
Show the original price crossed out next to the adjusted price.
gform.addAction( 'gpcp_after_update_pricing', function( productId, GWConditionalPricing ) {
var basePrice = GWConditionalPricing.getBasePrice( productId );
if ( ! basePrice ) {
return;
}
var $input = $( '#input_{0}_{1}'.format( GWConditionalPricing._formId, productId ) );
if ( ! $input.length ) {
return;
}
var $basePrice = $( '#base_price_{0}_{1}'.format( GWConditionalPricing._formId, productId ) );
// Remove base price if there is no discounted price.
if ( $input.text() === basePrice ) {
$basePrice.remove();
}
// Otherwise, add base price if it has not been added.
else if ( ! $basePrice.length ) {
$basePrice = '<span id="base_price_{0}_{1}" style="text-decoration:line-through;margin-right:0.3rem">{2}</span>'.format( GWConditionalPricing._formId, productId, basePrice );
$input.before( $basePrice );
}
} );
Since
This filter is available since GP Conditional Pricing 1.2.13