Merge pull request #1146 from woocommerce/pcp-1391-ditch-filter

Add filter for controlling the ditching of items/breakdown
This commit is contained in:
Emili Castells 2023-02-10 12:36:33 +01:00 committed by GitHub
commit 040e6d9d99
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -284,7 +284,14 @@ class PurchaseUnit {
$this->items() $this->items()
), ),
); );
if ( $ditch_items_when_mismatch && $this->ditch_items_when_mismatch( $this->amount(), ...$this->items() ) ) {
$ditch = $ditch_items_when_mismatch && $this->ditch_items_when_mismatch( $this->amount(), ...$this->items() );
/**
* The filter can be used to control when the items and totals breakdown are removed from PayPal order info.
*/
$ditch = apply_filters( 'ppcp_ditch_items_breakdown', $ditch, $this );
if ( $ditch ) {
unset( $purchase_unit['items'] ); unset( $purchase_unit['items'] );
unset( $purchase_unit['amount']['breakdown'] ); unset( $purchase_unit['amount']['breakdown'] );
} }