Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Save transaction status in order meta (526) #2427

Draft
wants to merge 7 commits into
base: trunk
Choose a base branch
from

Conversation

stracker-phil
Copy link
Collaborator

Description

This PR adds a new order-meta value with the PayPal transaction status. The purpose is helping third-party code to understand if an order is pending payment, authorized, or captured or refunded/voided.

When the transaction status changes, a new WP action fires to allow third-party code to take immediate action:

/**
 * Fires after the PayPal order status value was updated in the order meta table.
 *
 * @param WC_Abstract_Order $wc_order   The WooCommerce order. 
 * @param Order             $pp_order   The PayPal order.
 * @param string            $new_status The new status.
 * @param string            $old_status The old status.
 */
do_action(
    'woocommerce_paypal_payments_order_status_changed',
    $wc_order,
    $order,
    $new_status,
    $old_status
);

Implementation

This PR introduces a new OrderMetaManager class that contains the order-meta logic (reading and writing):

$meta = new OrderMetaManager( $wc_order, $order );
$meta->update_status();  // Saves the $order->status value to the WC order-meta table
$meta->persist();

$status = $meta->get_status();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant