Plugin not following WooCommerce developer recommendations for CRUD operations
-
Hello again!
the plugin is not following the WooCommerce developer guidelines regarding CRUD operations on WC orders. See: https://docs.woocommerce.com/document/developing-using-woocommerce-crud-objects/
Regarding orders you can fix it by add this modifications to your plugin:
diff --git a/pixelyoursite-pro/includes/class-events-manager.php b/pixelyoursite-pro/includes/class-events-manager.php index 8741c9da..426342c8 100644 --- a/pixelyoursite-pro/includes/class-events-manager.php +++ b/pixelyoursite-pro/includes/class-events-manager.php @@ -497,13 +497,14 @@ if ( isEventEnabled( 'woo_paypal_enabled' ) && is_checkout() && ! is_wc_endpoint if ( isEventEnabled( 'woo_purchase_enabled' ) && is_order_received_page() && isset( $_REQUEST['key'] ) ) { $order_id = (int) wc_get_order_id_by_order_key( $_REQUEST['key'] ); + $order = wc_get_order( $order_id );^M // skip if event was fired before - if ( PYS()->getOption( 'woo_purchase_on_transaction' ) && get_post_meta( $order_id, '_pys_purchase_event_fired', true ) ) { + if ( PYS()->getOption( 'woo_purchase_on_transaction' ) && $order->get_meta( '_pys_purchase_event_fired', true ) ) {^M return; } - update_post_meta( $order_id, '_pys_purchase_event_fired', true ); + $order->update_meta_data( '_pys_purchase_event_fired', true );^M $this->addStaticEvent( 'woo_purchase' ); @@ -776,6 +777,7 @@ public function setupWooLoopProductData() { $payment_key = getEddPaymentKey(); $order_id = (int) edd_get_purchase_id_by_key( $payment_key ); + $order = wc_get_order( $order_id );^M $status = edd_get_payment_status( $order_id, true ); // pending payment status used because we can't fire event on IPN @@ -784,11 +786,11 @@ public function setupWooLoopProductData() { } // skip if event was fired before - if ( PYS()->getOption( 'edd_purchase_on_transaction' ) && get_post_meta( $order_id, '_pys_purchase_event_fired', true ) ) { + if ( PYS()->getOption( 'edd_purchase_on_transaction' ) && $order->get_meta( '_pys_purchase_event_fired', true ) ) {^M return; } - update_post_meta( $order_id, '_pys_purchase_event_fired', true ); + $order->update_meta_data( '_pys_purchase_event_fired', true );^M $this->addStaticEvent( 'edd_purchase' ); return;
If you have a better way to provide code feedback I can use it.
Thanks so much!
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Plugin not following WooCommerce developer recommendations for CRUD operations’ is closed to new replies.