Plugin Directory

Changeset 3302010


Ignore:
Timestamp:
05/28/2025 08:03:38 AM (10 months ago)
Author:
flexcubed
Message:

v11.0.11

Location:
pitchprint
Files:
6 edited
1 copied

Legend:

Unmodified
Added
Removed
  • pitchprint/tags/11.0.11/functions/admin/orders.php

    r3294021 r3302010  
    9999    function handle_new_order( $order_id, $order ) {
    100100        $items = $order->get_items();
     101        $should_update_user_id = false;
    101102        $project_ids = [];
    102        
    103         $user_data = [
    104             'id' => $order->get_user_id(),
    105             'first_name' => $order->get_billing_first_name(),
    106             'last_name' => $order->get_billing_last_name(),
    107             'email' => $order->get_billing_email(),
    108             'info' => 'Order Id: ' . $order_id,
    109         ];
     103        $user_id = $order->get_user_id();
    110104   
    111105        foreach ( $items as $item ) {
     
    119113
    120114                    if ( !empty($pitchprint_customization['projectId']) ) {
     115                        if ( $user_id && $pitchprint_customization['userId'] === 'guest' ) {
     116                            $should_update_user_id = true;
     117                        }
    121118                        $project_ids[] = $pitchprint_customization['projectId'];
    122119                    }
     
    125122        }
    126123
    127         if (count($project_ids)) {
    128             $auth_key = 'Bearer ' . get_option('print_app_secret_key');
    129 
    130             $response = wp_remote_post(PITCHPRINT_UPDATE_ORDER_ENDPOINT, [
     124        if ( count($project_ids) ) {
     125            $auth_key = get_option( 'ppa_secret_key' );
     126            // Append order ID
     127            $response1 = wp_remote_post( 'https://api.pitchprint.com/runtime/append-project-order-id', [
    131128                'headers' => [ 'Authorization' => $auth_key ],
    132                 'body'    => json_encode([
     129                'body'    => json_encode( [
    133130                    'projectIds' => $project_ids,
    134                     'user'     => $user_data,
    135                 ]),
     131                    'orderId'    => $order_id,
     132                ] ),
    136133                'method'  => 'POST',
    137             ]);
     134            ] );
    138135
    139136            if ( is_wp_error( $response1 ) || wp_remote_retrieve_response_code( $response1 ) !== 200 ) {
    140                 error_log( '[PitchPrint] Failed to append order ID to projects: ' . print_r( $response, true ) );
     137                error_log( '[PitchPrint] Failed to append order ID to projects: ' . print_r( $response1, true ) );
     138            }
     139   
     140            // Append user ID if needed
     141            if ( $should_update_user_id ) {
     142                $response2 = wp_remote_post( 'https://api.pitchprint.com/runtime/append-project-user-id', [
     143                    'headers' => [ 'Authorization' => $auth_key ],
     144                    'body'    => json_encode( [
     145                        'projectIds' => $project_ids,
     146                        'userId'     => $user_id,
     147                    ] ),
     148                    'method'  => 'POST',
     149                ] );
     150
     151                if ( is_wp_error( $response2 ) || wp_remote_retrieve_response_code( $response2 ) !== 200 ) {
     152                    error_log( '[PitchPrint] Failed to append user ID to projects: ' . print_r( $response2, true ) );
     153                }
    141154            }
    142155        }
  • pitchprint/tags/11.0.11/pitchprint.php

    r3296178 r3302010  
    66*   Description:            A beautiful web based print customization app for your online store. Integrates with WooCommerce.
    77*   Author:                 PitchPrint, Inc.
    8 *   Version:                11.0.10
     8*   Version:                11.0.11
    99*   Author URI:             https://pitchprint.com
    1010*   Requires at least:      3.8
     
    4747             *  @var string
    4848            */
    49             public $version = '11.0.10';
     49            public $version = '11.0.11';
    5050
    5151            /**
  • pitchprint/tags/11.0.11/readme.txt

    r3296178 r3302010  
    44Requires at least: 3.8
    55Tested up to: 6.8
    6 Stable tag: 11.0.10
     6Stable tag: 11.0.11
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    172172
    173173== Changelog ==
     174
     175== 11.0.11 =
     176Minor fix to order details reporting
    174177
    175178== 11.0.10 =
  • pitchprint/trunk/functions/admin/orders.php

    r3294021 r3302010  
    9999    function handle_new_order( $order_id, $order ) {
    100100        $items = $order->get_items();
     101        $should_update_user_id = false;
    101102        $project_ids = [];
    102        
    103         $user_data = [
    104             'id' => $order->get_user_id(),
    105             'first_name' => $order->get_billing_first_name(),
    106             'last_name' => $order->get_billing_last_name(),
    107             'email' => $order->get_billing_email(),
    108             'info' => 'Order Id: ' . $order_id,
    109         ];
     103        $user_id = $order->get_user_id();
    110104   
    111105        foreach ( $items as $item ) {
     
    119113
    120114                    if ( !empty($pitchprint_customization['projectId']) ) {
     115                        if ( $user_id && $pitchprint_customization['userId'] === 'guest' ) {
     116                            $should_update_user_id = true;
     117                        }
    121118                        $project_ids[] = $pitchprint_customization['projectId'];
    122119                    }
     
    125122        }
    126123
    127         if (count($project_ids)) {
    128             $auth_key = 'Bearer ' . get_option('print_app_secret_key');
    129 
    130             $response = wp_remote_post(PITCHPRINT_UPDATE_ORDER_ENDPOINT, [
     124        if ( count($project_ids) ) {
     125            $auth_key = get_option( 'ppa_secret_key' );
     126            // Append order ID
     127            $response1 = wp_remote_post( 'https://api.pitchprint.com/runtime/append-project-order-id', [
    131128                'headers' => [ 'Authorization' => $auth_key ],
    132                 'body'    => json_encode([
     129                'body'    => json_encode( [
    133130                    'projectIds' => $project_ids,
    134                     'user'     => $user_data,
    135                 ]),
     131                    'orderId'    => $order_id,
     132                ] ),
    136133                'method'  => 'POST',
    137             ]);
     134            ] );
    138135
    139136            if ( is_wp_error( $response1 ) || wp_remote_retrieve_response_code( $response1 ) !== 200 ) {
    140                 error_log( '[PitchPrint] Failed to append order ID to projects: ' . print_r( $response, true ) );
     137                error_log( '[PitchPrint] Failed to append order ID to projects: ' . print_r( $response1, true ) );
     138            }
     139   
     140            // Append user ID if needed
     141            if ( $should_update_user_id ) {
     142                $response2 = wp_remote_post( 'https://api.pitchprint.com/runtime/append-project-user-id', [
     143                    'headers' => [ 'Authorization' => $auth_key ],
     144                    'body'    => json_encode( [
     145                        'projectIds' => $project_ids,
     146                        'userId'     => $user_id,
     147                    ] ),
     148                    'method'  => 'POST',
     149                ] );
     150
     151                if ( is_wp_error( $response2 ) || wp_remote_retrieve_response_code( $response2 ) !== 200 ) {
     152                    error_log( '[PitchPrint] Failed to append user ID to projects: ' . print_r( $response2, true ) );
     153                }
    141154            }
    142155        }
  • pitchprint/trunk/pitchprint.php

    r3296178 r3302010  
    66*   Description:            A beautiful web based print customization app for your online store. Integrates with WooCommerce.
    77*   Author:                 PitchPrint, Inc.
    8 *   Version:                11.0.10
     8*   Version:                11.0.11
    99*   Author URI:             https://pitchprint.com
    1010*   Requires at least:      3.8
     
    4747             *  @var string
    4848            */
    49             public $version = '11.0.10';
     49            public $version = '11.0.11';
    5050
    5151            /**
  • pitchprint/trunk/readme.txt

    r3296178 r3302010  
    44Requires at least: 3.8
    55Tested up to: 6.8
    6 Stable tag: 11.0.10
     6Stable tag: 11.0.11
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    172172
    173173== Changelog ==
     174
     175== 11.0.11 =
     176Minor fix to order details reporting
    174177
    175178== 11.0.10 =
Note: See TracChangeset for help on using the changeset viewer.