mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
Fix update plan price on webhook handler
This commit is contained in:
parent
84602ab9fa
commit
b477ec4ba4
1 changed files with 9 additions and 5 deletions
|
@ -70,8 +70,8 @@ class BillingPlanPricingChangeActivated implements RequestHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
$plan_id = wc_clean( wp_unslash( $request['resource']['id'] ?? '' ) );
|
$plan_id = wc_clean( wp_unslash( $request['resource']['id'] ?? '' ) );
|
||||||
$price = wc_clean( wp_unslash( $request['resource']['billing_cycles'][0]['pricing_scheme']['fixed_price']['value'] ?? '' ) );
|
if ( $plan_id && ! empty( $request['resource']['billing_cycles'] ) ) {
|
||||||
if ( $plan_id && $price ) {
|
$this->logger->info( 'Starting stuff...' );
|
||||||
$args = array(
|
$args = array(
|
||||||
'meta_key' => 'ppcp_subscription_plan',
|
'meta_key' => 'ppcp_subscription_plan',
|
||||||
);
|
);
|
||||||
|
@ -79,9 +79,13 @@ class BillingPlanPricingChangeActivated implements RequestHandler {
|
||||||
$products = wc_get_products( $args );
|
$products = wc_get_products( $args );
|
||||||
if ( is_array( $products ) ) {
|
if ( is_array( $products ) ) {
|
||||||
foreach ( $products as $product ) {
|
foreach ( $products as $product ) {
|
||||||
if ( $product->get_meta( 'ppcp_subscription_plan' )->id === $plan_id ) {
|
if ( $product->get_meta( 'ppcp_subscription_plan' )['id'] === $plan_id ) {
|
||||||
$product->update_meta_data( '_subscription_price', $price );
|
foreach ( $request['resource']['billing_cycles'] as $cycle ) {
|
||||||
$product->save();
|
if ( $cycle['tenure_type'] === 'REGULAR' ) {
|
||||||
|
$product->update_meta_data( '_subscription_price', $cycle['pricing_scheme']['fixed_price']['value'] );
|
||||||
|
$product->save();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue