• 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)
  • Plugin Author PixelYourSite

    (@pixelyoursite)

    Hi,

    Thanks for this.

    Unfortunately CRUD objects are supported from WooCommerce v3.0, and there are still some users on older versions (no joking!).

    I agree that we should make a version check and use this method when possible.

    However, do you see any issues with the current approach? I mean, is the purchase event fired correctly after a transaction takes place?

    Thread Starter quiron

    (@quiron)

    Hi, thanks for this fast response!

    ouch, ok, old versions.

    Yes, they are issues when using modern plugins. Actually I found it testing some of flat table plugins. This and other further improvements will relay on CRUD operations and I would say that implement the version check is quite straightforward for the win to use this plugin in big sites that need such performance features like the flat tables.

    Thanks a lot for your work.

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.