Plugin Directory

Changeset 3294021


Ignore:
Timestamp:
05/15/2025 10:52:58 AM (9 months ago)
Author:
flexcubed
Message:

v11.0.9

Location:
pitchprint
Files:
10 edited
1 copied

Legend:

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

    r3286188 r3294021  
    145145
    146146    function order_status_completed($order_id, $status_from, $status_to) {
    147     $pp_webhook_url = false;
    148 
    149     if ($status_to === "completed") $pp_webhook_url = 'order-complete';
    150     if ($status_to === "processing") $pp_webhook_url = 'order-processing';
    151 
    152     if ($pp_webhook_url) {
    153         $order = wc_get_order($order_id);
    154         $order_data = $order->get_data();
    155         $billing = $order_data['billing'];
    156         $billingEmail = $billing['email'];
    157         $billingPhone = $billing['phone'];
    158         $billingName = $billing['first_name'] . " " . $billing['last_name'];
    159 
    160         $addressArr = ['address_1', 'address_2', 'city', 'postcode', 'country'];
    161         $billingAddress = '';
    162         foreach ($addressArr as $addKey) {
    163             if (!empty($billing[$addKey])) {
    164                 $billingAddress .= $billing[$addKey] . ", ";
    165             }
    166         }
    167         $billingAddress = rtrim($billingAddress, ', ');
    168 
    169         $shippingName = $order_data['shipping']['first_name'] . " " . $order_data['shipping']['last_name'];
    170         $shippingAddress = $order->get_formatted_shipping_address();
    171         $status = $order_data['status'];
    172         $products = $order->get_items();
    173         $userId = $order_data['customer_id'];
    174         $items = array();
    175 
    176         foreach ($products as $item_key => $item_values) {
    177             $item_data = $item_values->get_data();
    178             $pprint = wc_get_order_item_meta($item_key, PITCHPRINT_CUSTOMIZATION_KEY);
    179             if (isset($pprint) && !empty($pprint)) $pprint = json_encode($pprint);
    180 
    181             $items[] = array(
    182                 'name' => $item_data['name'],
    183                 'id' => $item_data['product_id'],
    184                 'qty' => $item_data['quantity'],
    185                 'pitchprint' => $pprint
    186             );
    187         }
    188 
    189         // If empty Pitchprint value, then we won't trigger the webhook.
    190         $should_send = false;
    191         foreach ($items as $item) {
    192             if (!empty($item['pitchprint'])) {
    193                 $should_send = true;
    194                 break;
    195             }
    196         }
    197 
    198         if ($should_send) {
    199             $cred = \pitchprint\functions\general\fetch_credentials();
    200             $opts = array(
    201                 'products' => json_encode($items),
    202                 'client' => 'wp',
    203                 'billingEmail' => $billingEmail,
    204                 'billingPhone' => $billingPhone,
    205                 'billingName' => $billingName,
    206                 'billingAddress' => $billingAddress,
    207                 'shippingName' => $shippingName,
    208                 'shippingAddress' => $shippingAddress,
    209                 'orderId' => $order_id,
    210                 'customer' => $userId,
    211                 'status' => $status,
    212                 'apiKey' => get_option('ppa_api_key'),
    213                 'signature' => $cred['signature'],
    214                 'timestamp' => $cred['timestamp']
    215             );
    216 
    217             $response = wp_remote_post("https://api.pitchprint.io/runtime/$pp_webhook_url", array(
    218                 'headers' => array(
    219                     'Content-Type' => 'application/json'
    220                 ),
    221                 'body' => json_encode($opts),
    222                 'method' => 'POST',
    223                 'data_format' => 'body',
    224                 'timeout' => 20
    225             ));
    226 
    227             if (is_wp_error($response) || wp_remote_retrieve_response_code($response) !== 200) {
    228                 error_log('[PitchPrint] Webhook failed: ' . print_r($response, true));
    229             }
    230         }
    231     }
    232 }
     147        $pp_webhook_url = false;
     148
     149        if ($status_to === "completed") $pp_webhook_url = 'order-complete';
     150        if ($status_to === "processing") $pp_webhook_url = 'order-processing';
     151
     152        if ($pp_webhook_url) {
     153            $order = wc_get_order($order_id);
     154            $order_data = $order->get_data();
     155            $billing = $order_data['billing'];
     156            $billingEmail = $billing['email'];
     157            $billingPhone = $billing['phone'];
     158            $billingName = $billing['first_name'] . " " . $billing['last_name'];
     159
     160            $addressArr = ['address_1', 'address_2', 'city', 'postcode', 'country'];
     161            $billingAddress = '';
     162            foreach ($addressArr as $addKey) {
     163                if (!empty($billing[$addKey])) {
     164                    $billingAddress .= $billing[$addKey] . ", ";
     165                }
     166            }
     167            $billingAddress = rtrim($billingAddress, ', ');
     168
     169            $shippingName = $order_data['shipping']['first_name'] . " " . $order_data['shipping']['last_name'];
     170            $shippingAddress = $order->get_formatted_shipping_address();
     171            $status = $order_data['status'];
     172            $products = $order->get_items();
     173            $userId = $order_data['customer_id'];
     174            $items = array();
     175
     176            foreach ($products as $item_key => $item_values) {
     177                $item_data = $item_values->get_data();
     178                $pprint = null;
     179                foreach ($item_values->get_meta_data() as $meta) {
     180                    if ($meta->key === PITCHPRINT_CUSTOMIZATION_KEY) {
     181                        $pitchprint_customization = $meta->value;
     182                        if (is_string($pitchprint_customization)) {
     183                            $pitchprint_customization = json_decode($pitchprint_customization, true);
     184                        }
     185                        if (!empty($pitchprint_customization)) {
     186                            $pprint = json_encode($pitchprint_customization);
     187                        }
     188                        break;
     189                    }
     190                }
     191                $items[] = array(
     192                    'name' => $item_data['name'],
     193                    'id' => $item_data['product_id'],
     194                    'qty' => $item_data['quantity'],
     195                    'pitchprint' => $pprint
     196                );
     197            }
     198
     199            // If empty Pitchprint value, then we won't trigger the webhook.
     200            $should_send = false;
     201            foreach ($items as $item) {
     202                if (!empty($item['pitchprint'])) {
     203                    $should_send = true;
     204                    break;
     205                }
     206            }
     207
     208            if ($should_send) {
     209                $cred = \pitchprint\functions\general\fetch_credentials();
     210                $opts = array(
     211                    'products' => json_encode($items),
     212                    'client' => 'wp',
     213                    'billingEmail' => $billingEmail,
     214                    'billingPhone' => $billingPhone,
     215                    'billingName' => $billingName,
     216                    'billingAddress' => $billingAddress,
     217                    'shippingName' => $shippingName,
     218                    'shippingAddress' => $shippingAddress,
     219                    'orderId' => $order_id,
     220                    'customer' => $userId,
     221                    'status' => $status,
     222                    'apiKey' => get_option('ppa_api_key'),
     223                    'signature' => $cred['signature'],
     224                    'timestamp' => $cred['timestamp']
     225                );
     226
     227                $response = wp_remote_post("https://api.pitchprint.io/runtime/$pp_webhook_url", array(
     228                    'headers' => array(
     229                        'Content-Type' => 'application/json'
     230                    ),
     231                    'body' => json_encode($opts),
     232                    'method' => 'POST',
     233                    'data_format' => 'body',
     234                    'timeout' => 20
     235                ));
     236
     237                if (is_wp_error($response) || wp_remote_retrieve_response_code($response) !== 200) {
     238                    error_log('[PitchPrint] Webhook failed: ' . print_r($response, true));
     239                }
     240            }
     241        }
     242    }
  • pitchprint/tags/11.0.9/functions/front/customize_button.php

    r3286188 r3294021  
    5858        $design_id = $set_option[0];
    5959        $design_id = apply_filters('set_pitchprint_design_id', $design_id);
     60        $upload_path = file_exists(ABSPATH . 'pitchprint/uploader') ? 'pitchprint/uploader/' : 'wp-content/plugins/pitchprint/uploader/';
    6061
    6162        wc_enqueue_js("
     
    6970                    pdfDownload: {$pdf_download},
    7071                    useDesignPrevAsProdImage: {$use_design_preview},
    71                     uploadUrl: '" . site_url('pitchprint/uploader/') . "',
     72                    uploadUrl: '" . site_url($upload_path) . "',
    7273                    userId: '{$user_id}',
    7374                    langCode: '{$lang_code}',
  • pitchprint/tags/11.0.9/functions/general/emails.php

    r3286188 r3294021  
    1919
    2020        for ($i = 0; $i < $num_pages; $i++) {
    21             $html .= '<tr><td colspan="2" style="text-align:left; padding: 10px 0;"><img src="' . PITCHPRINT_PREVIEWS_BASE . $project_id . '_' . ($i + 1) . '.jpg" width="180px; margin-right:10px;"/></td></tr>';
     21            $html .= '<tr><td colspan="2" style="text-align:left; padding: 10px 0;"><img src="' . PITCHPRINT_PREVIEWS_BASE . $project_id . '_' . ($i + 1) . '.jpg" style="width:180px; margin-right:10px;"/></td></tr>';
    2222        }
    2323
  • pitchprint/tags/11.0.9/pitchprint.php

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

    r3286188 r3294021  
    44Requires at least: 3.8
    55Tested up to: 6.8
    6 Stable tag: 11.0.8
     6Stable tag: 11.0.9
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    172172
    173173== Changelog ==
     174
     175== 11.0.9 =
     176Fixed HTML Styling for order emails
     177Included a check to verify location of the upload folder
    174178
    175179== 11.0.8 =
  • pitchprint/trunk/functions/admin/orders.php

    r3286188 r3294021  
    145145
    146146    function order_status_completed($order_id, $status_from, $status_to) {
    147     $pp_webhook_url = false;
    148 
    149     if ($status_to === "completed") $pp_webhook_url = 'order-complete';
    150     if ($status_to === "processing") $pp_webhook_url = 'order-processing';
    151 
    152     if ($pp_webhook_url) {
    153         $order = wc_get_order($order_id);
    154         $order_data = $order->get_data();
    155         $billing = $order_data['billing'];
    156         $billingEmail = $billing['email'];
    157         $billingPhone = $billing['phone'];
    158         $billingName = $billing['first_name'] . " " . $billing['last_name'];
    159 
    160         $addressArr = ['address_1', 'address_2', 'city', 'postcode', 'country'];
    161         $billingAddress = '';
    162         foreach ($addressArr as $addKey) {
    163             if (!empty($billing[$addKey])) {
    164                 $billingAddress .= $billing[$addKey] . ", ";
    165             }
    166         }
    167         $billingAddress = rtrim($billingAddress, ', ');
    168 
    169         $shippingName = $order_data['shipping']['first_name'] . " " . $order_data['shipping']['last_name'];
    170         $shippingAddress = $order->get_formatted_shipping_address();
    171         $status = $order_data['status'];
    172         $products = $order->get_items();
    173         $userId = $order_data['customer_id'];
    174         $items = array();
    175 
    176         foreach ($products as $item_key => $item_values) {
    177             $item_data = $item_values->get_data();
    178             $pprint = wc_get_order_item_meta($item_key, PITCHPRINT_CUSTOMIZATION_KEY);
    179             if (isset($pprint) && !empty($pprint)) $pprint = json_encode($pprint);
    180 
    181             $items[] = array(
    182                 'name' => $item_data['name'],
    183                 'id' => $item_data['product_id'],
    184                 'qty' => $item_data['quantity'],
    185                 'pitchprint' => $pprint
    186             );
    187         }
    188 
    189         // If empty Pitchprint value, then we won't trigger the webhook.
    190         $should_send = false;
    191         foreach ($items as $item) {
    192             if (!empty($item['pitchprint'])) {
    193                 $should_send = true;
    194                 break;
    195             }
    196         }
    197 
    198         if ($should_send) {
    199             $cred = \pitchprint\functions\general\fetch_credentials();
    200             $opts = array(
    201                 'products' => json_encode($items),
    202                 'client' => 'wp',
    203                 'billingEmail' => $billingEmail,
    204                 'billingPhone' => $billingPhone,
    205                 'billingName' => $billingName,
    206                 'billingAddress' => $billingAddress,
    207                 'shippingName' => $shippingName,
    208                 'shippingAddress' => $shippingAddress,
    209                 'orderId' => $order_id,
    210                 'customer' => $userId,
    211                 'status' => $status,
    212                 'apiKey' => get_option('ppa_api_key'),
    213                 'signature' => $cred['signature'],
    214                 'timestamp' => $cred['timestamp']
    215             );
    216 
    217             $response = wp_remote_post("https://api.pitchprint.io/runtime/$pp_webhook_url", array(
    218                 'headers' => array(
    219                     'Content-Type' => 'application/json'
    220                 ),
    221                 'body' => json_encode($opts),
    222                 'method' => 'POST',
    223                 'data_format' => 'body',
    224                 'timeout' => 20
    225             ));
    226 
    227             if (is_wp_error($response) || wp_remote_retrieve_response_code($response) !== 200) {
    228                 error_log('[PitchPrint] Webhook failed: ' . print_r($response, true));
    229             }
    230         }
    231     }
    232 }
     147        $pp_webhook_url = false;
     148
     149        if ($status_to === "completed") $pp_webhook_url = 'order-complete';
     150        if ($status_to === "processing") $pp_webhook_url = 'order-processing';
     151
     152        if ($pp_webhook_url) {
     153            $order = wc_get_order($order_id);
     154            $order_data = $order->get_data();
     155            $billing = $order_data['billing'];
     156            $billingEmail = $billing['email'];
     157            $billingPhone = $billing['phone'];
     158            $billingName = $billing['first_name'] . " " . $billing['last_name'];
     159
     160            $addressArr = ['address_1', 'address_2', 'city', 'postcode', 'country'];
     161            $billingAddress = '';
     162            foreach ($addressArr as $addKey) {
     163                if (!empty($billing[$addKey])) {
     164                    $billingAddress .= $billing[$addKey] . ", ";
     165                }
     166            }
     167            $billingAddress = rtrim($billingAddress, ', ');
     168
     169            $shippingName = $order_data['shipping']['first_name'] . " " . $order_data['shipping']['last_name'];
     170            $shippingAddress = $order->get_formatted_shipping_address();
     171            $status = $order_data['status'];
     172            $products = $order->get_items();
     173            $userId = $order_data['customer_id'];
     174            $items = array();
     175
     176            foreach ($products as $item_key => $item_values) {
     177                $item_data = $item_values->get_data();
     178                $pprint = null;
     179                foreach ($item_values->get_meta_data() as $meta) {
     180                    if ($meta->key === PITCHPRINT_CUSTOMIZATION_KEY) {
     181                        $pitchprint_customization = $meta->value;
     182                        if (is_string($pitchprint_customization)) {
     183                            $pitchprint_customization = json_decode($pitchprint_customization, true);
     184                        }
     185                        if (!empty($pitchprint_customization)) {
     186                            $pprint = json_encode($pitchprint_customization);
     187                        }
     188                        break;
     189                    }
     190                }
     191                $items[] = array(
     192                    'name' => $item_data['name'],
     193                    'id' => $item_data['product_id'],
     194                    'qty' => $item_data['quantity'],
     195                    'pitchprint' => $pprint
     196                );
     197            }
     198
     199            // If empty Pitchprint value, then we won't trigger the webhook.
     200            $should_send = false;
     201            foreach ($items as $item) {
     202                if (!empty($item['pitchprint'])) {
     203                    $should_send = true;
     204                    break;
     205                }
     206            }
     207
     208            if ($should_send) {
     209                $cred = \pitchprint\functions\general\fetch_credentials();
     210                $opts = array(
     211                    'products' => json_encode($items),
     212                    'client' => 'wp',
     213                    'billingEmail' => $billingEmail,
     214                    'billingPhone' => $billingPhone,
     215                    'billingName' => $billingName,
     216                    'billingAddress' => $billingAddress,
     217                    'shippingName' => $shippingName,
     218                    'shippingAddress' => $shippingAddress,
     219                    'orderId' => $order_id,
     220                    'customer' => $userId,
     221                    'status' => $status,
     222                    'apiKey' => get_option('ppa_api_key'),
     223                    'signature' => $cred['signature'],
     224                    'timestamp' => $cred['timestamp']
     225                );
     226
     227                $response = wp_remote_post("https://api.pitchprint.io/runtime/$pp_webhook_url", array(
     228                    'headers' => array(
     229                        'Content-Type' => 'application/json'
     230                    ),
     231                    'body' => json_encode($opts),
     232                    'method' => 'POST',
     233                    'data_format' => 'body',
     234                    'timeout' => 20
     235                ));
     236
     237                if (is_wp_error($response) || wp_remote_retrieve_response_code($response) !== 200) {
     238                    error_log('[PitchPrint] Webhook failed: ' . print_r($response, true));
     239                }
     240            }
     241        }
     242    }
  • pitchprint/trunk/functions/front/customize_button.php

    r3286188 r3294021  
    5858        $design_id = $set_option[0];
    5959        $design_id = apply_filters('set_pitchprint_design_id', $design_id);
     60        $upload_path = file_exists(ABSPATH . 'pitchprint/uploader') ? 'pitchprint/uploader/' : 'wp-content/plugins/pitchprint/uploader/';
    6061
    6162        wc_enqueue_js("
     
    6970                    pdfDownload: {$pdf_download},
    7071                    useDesignPrevAsProdImage: {$use_design_preview},
    71                     uploadUrl: '" . site_url('pitchprint/uploader/') . "',
     72                    uploadUrl: '" . site_url($upload_path) . "',
    7273                    userId: '{$user_id}',
    7374                    langCode: '{$lang_code}',
  • pitchprint/trunk/functions/general/emails.php

    r3286188 r3294021  
    1919
    2020        for ($i = 0; $i < $num_pages; $i++) {
    21             $html .= '<tr><td colspan="2" style="text-align:left; padding: 10px 0;"><img src="' . PITCHPRINT_PREVIEWS_BASE . $project_id . '_' . ($i + 1) . '.jpg" width="180px; margin-right:10px;"/></td></tr>';
     21            $html .= '<tr><td colspan="2" style="text-align:left; padding: 10px 0;"><img src="' . PITCHPRINT_PREVIEWS_BASE . $project_id . '_' . ($i + 1) . '.jpg" style="width:180px; margin-right:10px;"/></td></tr>';
    2222        }
    2323
  • pitchprint/trunk/pitchprint.php

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

    r3286188 r3294021  
    44Requires at least: 3.8
    55Tested up to: 6.8
    6 Stable tag: 11.0.8
     6Stable tag: 11.0.9
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    172172
    173173== Changelog ==
     174
     175== 11.0.9 =
     176Fixed HTML Styling for order emails
     177Included a check to verify location of the upload folder
    174178
    175179== 11.0.8 =
Note: See TracChangeset for help on using the changeset viewer.