Plugin Directory

Changeset 3275461


Ignore:
Timestamp:
04/17/2025 07:18:47 AM (12 months ago)
Author:
flexcubed
Message:

Update version to 11.0.5 and enhance order handling for PitchPrint projects

Location:
pitchprint
Files:
10 edited
1 copied

Legend:

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

    r3274379 r3275461  
    9696        return $formatted_meta;
    9797    }
     98
     99    function handle_new_order( $order_id, $order ) {
     100        $items = $order->get_items();
     101        $should_update_user_id = false;
     102        $project_ids = [];
     103        $user_id = $order->get_user_id();
     104   
     105        foreach ( $items as $item ) {
     106            foreach ( $item->get_meta_data() as $meta ) {
     107                if ( $meta->key === PITCHPRINT_CUSTOMIZATION_KEY ) {
     108                    $pitchprint_customization = $meta->value;
     109
     110                    if ( is_string($pitchprint_customization) ) {
     111                        $pitchprint_customization = json_decode( $pitchprint_customization, true );
     112                    }
     113
     114                    if ( !empty($pitchprint_customization['projectId']) ) {
     115                        if ( $user_id && $pitchprint_customization['userId'] === 'guest' ) {
     116                            $should_update_user_id = true;
     117                        }
     118                        $project_ids[] = $pitchprint_customization['projectId'];
     119                    }
     120                }
     121            }
     122        }
     123
     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', [
     128                'headers' => [ 'Authorization' => $auth_key ],
     129                'body'    => json_encode( [
     130                    'projectIds' => $project_ids,
     131                    'orderId'    => $order_id,
     132                ] ),
     133                'method'  => 'POST',
     134            ] );
     135
     136            if ( is_wp_error( $response1 ) || wp_remote_retrieve_response_code( $response1 ) !== 200 ) {
     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                }
     154            }
     155        }
     156    }
     157   
    98158
    99159    function order_status_completed($order_id, $status_from, $status_to) {
  • pitchprint/tags/11.0.5/functions/general/customization.php

    r3270976 r3275461  
    66        if (!isset($_COOKIE[PITCHPRINT_CUSTOMIZATION_KEY])) {
    77            $token = bin2hex(random_bytes(16));
    8             setcookie(PITCHPRINT_CUSTOMIZATION_KEY, $token, time() + PITCHPRINT_CUSTOMIZATION_DURATION, '/');
     8            if (!headers_sent()) {
     9                setcookie(PITCHPRINT_CUSTOMIZATION_KEY, $token, time() + PITCHPRINT_CUSTOMIZATION_DURATION, '/');
     10            }
    911        }
    1012    }
     
    1618        // Generate a random token for the user (guest or signed-in)
    1719        $token = bin2hex(random_bytes(16));
    18         setcookie(PITCHPRINT_CUSTOMIZATION_KEY, $token, time() + PITCHPRINT_CUSTOMIZATION_DURATION, '/');
     20        if (!headers_sent()) {
     21            setcookie(PITCHPRINT_CUSTOMIZATION_KEY, $token, time() + PITCHPRINT_CUSTOMIZATION_DURATION, '/');
     22        }
    1923        return $token;
    2024    }
     
    4347        return TRUE;
    4448    }
    45    
  • pitchprint/tags/11.0.5/functions/general/init_hooks.php

    r3274379 r3275461  
    6464
    6565        add_action('woocommerce_order_status_changed', 'pitchprint\\functions\\admin\\order_status_completed',10,3);
     66        add_action('woocommerce_new_order', 'pitchprint\\functions\\admin\\handle_new_order',10,2);
    6667
    6768        // add the customization info to the order email
  • pitchprint/tags/11.0.5/pitchprint.php

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

    r3274379 r3275461  
    44Requires at least: 3.8
    55Tested up to: 6.7
    6 Stable tag: 11.0.4
     6Stable tag: 11.0.5
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    6464**Data Form Module** - Displays a Quick-edit Form where your customers can simply type in their details and be done with. It is suitable for quick edits without having to manipulate directly on the canvas.
    6565
    66 !(Data Form)[https://pitchprint.com/assets/img/use/data-form-new.png]
    67 
    6866**Template Colour Module** - Change the template image colour of a design product without going outside of the editor.
    6967
    70 !(Template Color Module)[https://pitchprint.com/assets/img/use/template-color-module.png]
    71 
    7268**Page Loader** - Load additional pages into designs from an assigned source design. Perfect for Magazines, Menu, Programmes, Business Cards, Swatch Cards, Direct Mail Marketing, Brochures etc.
    7369
    74 !(Page Loader Module)[https://pitchprint.com/assets/img/use/page-loader.png]
    75 
    7670**Display Modes** - Configure how the application appears in your product page with our 3 different display mode options to suit any of your product needs.
    7771
    7872**Layouts** - Enabling users to create different layout and assign them to different sets of designs based on your unique website need basis.
    7973
    80 !(Layouts)[https://pitchprint.com/assets/img/use/layout.png]
    81 
    8274**Canvas Adjuster** - Large prints come in different shapes and sizes, with this module you can adjust the canvas dimensions before or during designing. You can opt for custom dimensions or pick from a list of pre-set values.
    8375
    84 !(Canvas Adjuster)[https://pitchprint.com/assets/img/use/canvas-adjuster-new.png]
    85 
    8676**Smart Sizes** - Create multiple variations of a single design by varying the canvas size and elements’ properties to come up with entirely different looking layouts. i.e. Landscape, Portrait, Square in seconds saving you time to focus on what matters, the customers!
    8777
    88 !(Smart Sizes)[https://pitchprint.com/assets/img/use/smart-resize.png]
    89 
    9078**High Res** - You get high resolution print-ready PDF with crisp, clean vector elements in either CMYK with SPOT colors or RGB format. In addition, you can download files as JPEG or PNG.
    9179
    92 !(High Res)[https://pitchprint.com/assets/img/use/transp-high-res.png]
    93 
    9480**Variable Data** - An API that allows you to programmatically create multiple print-ready PDF files without launching the design editor. Perfect for business cards, direct mail marketing etc.
    9581
    96 !(Variable Data)[https://pitchprint.com/assets/img/use/spark-new.png]
    97 
    9882**Styling** - From the language to the themes and layout, you can customize the app to blend right into your store’s look and feel. Include your own CSS or Custom JavaScript code to add functionalities. More so, you can edit the HTML to remove features you don’t need.
    9983
    100 !(Styling)[https://pitchprint.com/assets/img/use/styling.png]
    101 
    10284**Google Fonts** - Search and use Google Fonts directly in the design editor. Add Google fonts or upload your own TTF or OTF, the choice is all yours!!!
    10385
    104 !(Fonts)[https://pitchprint.com/assets/img/use/fonts.gif]
    105 
    10686**Pixabay** - We have also integrated Pixabay which is a collection of royalty free photos and illustrations. And so much more!!!
    107 
    108 !(Pixabay)[https://pitchprint.com/assets/img/use/pixabay-lrg.gif]
    10987
    11088
     
    193171
    194172== Changelog ==
     173
     174== 11.0.5 =
     175Plugin reports and updates orderId against a PitchPrint project
     176Updates the userId, if a user was a guest when an order was placed
    195177
    196178== 11.0.4 =
  • pitchprint/trunk/functions/admin/orders.php

    r3274379 r3275461  
    9696        return $formatted_meta;
    9797    }
     98
     99    function handle_new_order( $order_id, $order ) {
     100        $items = $order->get_items();
     101        $should_update_user_id = false;
     102        $project_ids = [];
     103        $user_id = $order->get_user_id();
     104   
     105        foreach ( $items as $item ) {
     106            foreach ( $item->get_meta_data() as $meta ) {
     107                if ( $meta->key === PITCHPRINT_CUSTOMIZATION_KEY ) {
     108                    $pitchprint_customization = $meta->value;
     109
     110                    if ( is_string($pitchprint_customization) ) {
     111                        $pitchprint_customization = json_decode( $pitchprint_customization, true );
     112                    }
     113
     114                    if ( !empty($pitchprint_customization['projectId']) ) {
     115                        if ( $user_id && $pitchprint_customization['userId'] === 'guest' ) {
     116                            $should_update_user_id = true;
     117                        }
     118                        $project_ids[] = $pitchprint_customization['projectId'];
     119                    }
     120                }
     121            }
     122        }
     123
     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', [
     128                'headers' => [ 'Authorization' => $auth_key ],
     129                'body'    => json_encode( [
     130                    'projectIds' => $project_ids,
     131                    'orderId'    => $order_id,
     132                ] ),
     133                'method'  => 'POST',
     134            ] );
     135
     136            if ( is_wp_error( $response1 ) || wp_remote_retrieve_response_code( $response1 ) !== 200 ) {
     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                }
     154            }
     155        }
     156    }
     157   
    98158
    99159    function order_status_completed($order_id, $status_from, $status_to) {
  • pitchprint/trunk/functions/general/customization.php

    r3270976 r3275461  
    66        if (!isset($_COOKIE[PITCHPRINT_CUSTOMIZATION_KEY])) {
    77            $token = bin2hex(random_bytes(16));
    8             setcookie(PITCHPRINT_CUSTOMIZATION_KEY, $token, time() + PITCHPRINT_CUSTOMIZATION_DURATION, '/');
     8            if (!headers_sent()) {
     9                setcookie(PITCHPRINT_CUSTOMIZATION_KEY, $token, time() + PITCHPRINT_CUSTOMIZATION_DURATION, '/');
     10            }
    911        }
    1012    }
     
    1618        // Generate a random token for the user (guest or signed-in)
    1719        $token = bin2hex(random_bytes(16));
    18         setcookie(PITCHPRINT_CUSTOMIZATION_KEY, $token, time() + PITCHPRINT_CUSTOMIZATION_DURATION, '/');
     20        if (!headers_sent()) {
     21            setcookie(PITCHPRINT_CUSTOMIZATION_KEY, $token, time() + PITCHPRINT_CUSTOMIZATION_DURATION, '/');
     22        }
    1923        return $token;
    2024    }
     
    4347        return TRUE;
    4448    }
    45    
  • pitchprint/trunk/functions/general/init_hooks.php

    r3274379 r3275461  
    6464
    6565        add_action('woocommerce_order_status_changed', 'pitchprint\\functions\\admin\\order_status_completed',10,3);
     66        add_action('woocommerce_new_order', 'pitchprint\\functions\\admin\\handle_new_order',10,2);
    6667
    6768        // add the customization info to the order email
  • pitchprint/trunk/pitchprint.php

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

    r3274379 r3275461  
    44Requires at least: 3.8
    55Tested up to: 6.7
    6 Stable tag: 11.0.4
     6Stable tag: 11.0.5
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    6464**Data Form Module** - Displays a Quick-edit Form where your customers can simply type in their details and be done with. It is suitable for quick edits without having to manipulate directly on the canvas.
    6565
    66 !(Data Form)[https://pitchprint.com/assets/img/use/data-form-new.png]
    67 
    6866**Template Colour Module** - Change the template image colour of a design product without going outside of the editor.
    6967
    70 !(Template Color Module)[https://pitchprint.com/assets/img/use/template-color-module.png]
    71 
    7268**Page Loader** - Load additional pages into designs from an assigned source design. Perfect for Magazines, Menu, Programmes, Business Cards, Swatch Cards, Direct Mail Marketing, Brochures etc.
    7369
    74 !(Page Loader Module)[https://pitchprint.com/assets/img/use/page-loader.png]
    75 
    7670**Display Modes** - Configure how the application appears in your product page with our 3 different display mode options to suit any of your product needs.
    7771
    7872**Layouts** - Enabling users to create different layout and assign them to different sets of designs based on your unique website need basis.
    7973
    80 !(Layouts)[https://pitchprint.com/assets/img/use/layout.png]
    81 
    8274**Canvas Adjuster** - Large prints come in different shapes and sizes, with this module you can adjust the canvas dimensions before or during designing. You can opt for custom dimensions or pick from a list of pre-set values.
    8375
    84 !(Canvas Adjuster)[https://pitchprint.com/assets/img/use/canvas-adjuster-new.png]
    85 
    8676**Smart Sizes** - Create multiple variations of a single design by varying the canvas size and elements’ properties to come up with entirely different looking layouts. i.e. Landscape, Portrait, Square in seconds saving you time to focus on what matters, the customers!
    8777
    88 !(Smart Sizes)[https://pitchprint.com/assets/img/use/smart-resize.png]
    89 
    9078**High Res** - You get high resolution print-ready PDF with crisp, clean vector elements in either CMYK with SPOT colors or RGB format. In addition, you can download files as JPEG or PNG.
    9179
    92 !(High Res)[https://pitchprint.com/assets/img/use/transp-high-res.png]
    93 
    9480**Variable Data** - An API that allows you to programmatically create multiple print-ready PDF files without launching the design editor. Perfect for business cards, direct mail marketing etc.
    9581
    96 !(Variable Data)[https://pitchprint.com/assets/img/use/spark-new.png]
    97 
    9882**Styling** - From the language to the themes and layout, you can customize the app to blend right into your store’s look and feel. Include your own CSS or Custom JavaScript code to add functionalities. More so, you can edit the HTML to remove features you don’t need.
    9983
    100 !(Styling)[https://pitchprint.com/assets/img/use/styling.png]
    101 
    10284**Google Fonts** - Search and use Google Fonts directly in the design editor. Add Google fonts or upload your own TTF or OTF, the choice is all yours!!!
    10385
    104 !(Fonts)[https://pitchprint.com/assets/img/use/fonts.gif]
    105 
    10686**Pixabay** - We have also integrated Pixabay which is a collection of royalty free photos and illustrations. And so much more!!!
    107 
    108 !(Pixabay)[https://pitchprint.com/assets/img/use/pixabay-lrg.gif]
    10987
    11088
     
    193171
    194172== Changelog ==
     173
     174== 11.0.5 =
     175Plugin reports and updates orderId against a PitchPrint project
     176Updates the userId, if a user was a guest when an order was placed
    195177
    196178== 11.0.4 =
Note: See TracChangeset for help on using the changeset viewer.