Add filter for controlling the ditching of items/breakdown

This commit is contained in:
Alex P 2023-01-31 10:35:30 +02:00
parent 3336468f64
commit 3d3115f99d
No known key found for this signature in database
GPG key ID: 54487A734A204D71

View file

@ -284,7 +284,14 @@ class PurchaseUnit {
$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['amount']['breakdown'] );
}