Plugin Directory

Changeset 3082893


Ignore:
Timestamp:
05/08/2024 01:21:32 AM (23 months ago)
Author:
shipbubble
Message:

Critical checkoutand backend dashboard fixes

Location:
shipbubble
Files:
45 added
3 edited

Legend:

Unmodified
Added
Removed
  • shipbubble/trunk/admin/woocommerce/orders.php

    r3003454 r3082893  
    1919
    2020    $serializedShipment = get_post_meta($order_id, 'shipbubble_shipment_details')[0];
    21 
    22     if (strlen($shipbubbleOrderId) < 1 && !shipbubble_data_is_serialized($serializedShipment)) {
     21    $style = "background-color: #000; color: #FFF; padding: 4px 16px; border: 1px solid #000; border-radius: 3px; cursor: not-allowed;";
     22
     23    if (strlen($shipbubbleOrderId) < 1 && !shipbubble_data_is_serialized($serializedShipment))
     24    {
    2325        $msg = "Unable to process this order for shipment";
    2426        $output = '<div id="message" class="notice notice-warning is-dismissible">
     
    3133        echo $output;
    3234
    33         echo '<button type="button" onclick="alert(\'' . $msg . '\')" title="' . $msg . '" style="background-color: #000; color: #FFF; padding: 4px 16px; border: 1px solid #000; border-radius: 3px; cursor: not-allowed;">
     35        echo '<button type="button" onclick="alert(\''. $msg . '\')" title="' . $msg . '" style="'.$style.'">
    3436            Create Shipment via Shipbubble
    3537        </button>';
     
    3941    $shipmentDetailsArray = unserialize($serializedShipment);
    4042
    41     if ($shipmentDetailsArray === false) {
    42         return;
    43     }
    44 
     43    if ($shipmentDetailsArray === false)
     44    {
     45        return;
     46    }
     47   
    4548    // error_log(print_r($shipmentDetailsArray, true));
    4649    if (!count($shipmentDetailsArray)) {
     
    5356    // Get Shipping Data
    5457    $shippingData = $order->data['shipping'];
     58    $shippingPhone = $order->data['billing']['phone'];
    5559    $orderAddress = sb_create_address($shippingData['address_1'], $shippingData['city'], $shippingData['state'], $shippingData['country']);
     60    $orderPhone = get_post_meta($order_id, 'shipbubble_delivery_phone', true);
     61
     62    if (empty($orderPhone)) {
     63        $orderPhone = $shippingPhone;
     64        update_post_meta($order_id, 'shipbubble_delivery_phone', $orderPhone);
     65    }
    5666
    5767    // Get Delivery Address
    5868    $shipbubbleDeliveryAddress = get_post_meta($order_id, 'shipbubble_delivery_address', true);
    59 
     69   
    6070    // serialize shipment
    6171    $serializedShipment = serialize($shipmentDetailsArray);
     
    7181    //if (strlen($shipbubbleOrderId) < 1 && !sb_compare_addresses($shipbubbleDeliveryAddress, $orderAddress) && $hrsInterval < SHIPBUBBLE_REQUEST_TOKEN_EXPIRY && !is_null($shipment)) {
    7282
    73     // set flag to regenerate token
    74     $regenerateToken = false;
    75     $reason = '';
    76 
    77     // Check token has expired and shipbubble id doesn't exist to enable flag
    78     if (strlen($shipbubbleOrderId) < 1 && $hrsInterval > SHIPBUBBLE_REQUEST_TOKEN_EXPIRY) {
    79         $regenerateToken = true;
    80         $reason = 'TOKEN_EXPIRED';
    81     }
    82 
    83     // Check address has changed under 48hrs to enable flag
    84     if (!sb_compare_addresses($shipbubbleDeliveryAddress, $orderAddress) && $hrsInterval < SHIPBUBBLE_REQUEST_TOKEN_EXPIRY) {
    85         $regenerateToken = true;
    86         $reason = 'ADDRESS_CHANGED';
    87     }
    88 
    89     if ($regenerateToken && !is_null($shipment)) {
    90         // regenerate token
    91         $regeneratedMeta = shipbubble_regenerate_rate_token($order, $shipment, $reason);
    92 
    93         // update db
    94         if (count($regeneratedMeta) && isset($regeneratedMeta['request_token'])) {
    95             // set order id to meta
    96             $regeneratedMeta['order_id'] = $order_id;
    97             $serializedShipment = serialize($regeneratedMeta);
    98 
    99             update_post_meta($order_id, 'shipbubble_shipment_details', $serializedShipment);
    100             update_post_meta($order_id, 'shipbubble_delivery_address', $orderAddress);
    101         } else {
    102             if (isset($regeneratedMeta['errors'])) {
    103                 $message = $regeneratedMeta["errors"] . ' when regenerating shipbubble token';
    104                 $output = '<div id="message" class="notice notice-warning is-dismissible">
    105                     <p>' . $message . '</p>
    106                    
    107                     <button type="button" class="notice-dismiss">
    108                         <span class="screen-reader-text">Dismiss this notice.</span>
    109                     </button>
    110                 </div>';
    111 
    112                 echo $output;
    113             }
    114         }
     83    $disable = false;
     84    $disabled = "";
     85
     86
     87    // Check address has changed or token has expired
     88    if (!sb_compare_addresses($shipbubbleDeliveryAddress, $orderAddress) || $hrsInterval > SHIPBUBBLE_REQUEST_TOKEN_EXPIRY || $orderPhone != $shippingPhone)
     89    {
     90        $disable = true;
     91        $disabled = "disabled='disabled'";
     92    }
     93
     94
     95    if (!$disable) {
     96        $style = "background-color: #FF5170; color: #FFF; padding: 4px 16px; border: 1px solid #FF5170; border-radius: 3px; cursor: pointer;";
    11597    }
    11698
    11799?>
    118     <?php if (strlen($shipbubbleOrderId) < 1 && !is_null($shipment)) : ?>
     100    <?php if (strlen($shipbubbleOrderId) < 1 && !is_null($shipment)): ?>
    119101        <input type="hidden" id="wc_order_id" name="wc_order_id" value='<?php echo esc_html($order->get_id()); ?>' />
    120102
    121         <button id="create-shipment" style="background-color: #FF5170; color: #FFF; padding: 4px 16px; border: 1px solid #FF5170; border-radius: 3px; cursor: pointer;">
     103        <button id="create-shipment" style="<?php echo $style?>" <?php echo $disabled ?>>
    122104            Create Shipment via Shipbubble
    123105        </button>
  • shipbubble/trunk/readme.txt

    r3080029 r3082893  
    55Requires at least: 4.0
    66Tested up to: 6.3
    7 Stable tag: 2.3
     7Stable tag: 2.4
    88Requires PHP: 5.6
    99License: GPLv3 or later
     
    5151
    5252== Changelog ==
    53 = 0.1 =
    54 * Initial release.
     53= 2.4 =
     54* Critical checkoutand backend dashboard fixes
     55
     56= 2.3 =
     57* Handle plugin incompatibility for woocommerce block pages
     58
     59= 2.2.1 =
     60* Small fix for multicurrency store symbol
     61
     62= 2.2 =
     63* Fix scenario for customers checking out without paying for delivery
     64
     65= 2.1 =
     66* Support for multi currency checkout
     67
     68= 2.0.2 =
     69* Bug fix for pickup option on checkout
     70
     71= 2.0.1 =
     72* Bug fix for pickup option on checkout
     73
     74= 2.0 =
     75* Support for non physical goods at checkout.
     76
     77= 1.9 =
     78* Important checkout UX Fix - handling when user edits checkout details.
     79
     80= 1.8 =
     81* Fixes & Improvements
     82
     83= 1.7.2 =
     84* Admin process shipment bug fix.
     85
     86= 1.7.1 =
     87* Fixed checkout bug for other shipping methods (if available).
     88
     89= 1.7 =
     90* Dimension sorting for DHL packages, Fixed some more bugs.
     91
     92= 1.6 =
     93* Fixed orders page error for other shipping methods.
     94
     95= 1.5 =
     96* Disable other shipping options option.
     97
     98= 1.4 =
     99* set selected shipbubble option as checkout shipping option.
     100
     101= 1.3 =
     102* Critical checkout support fix.
     103
     104= 1.1 =
     105* International shipping support.
     106
     107= 1.0.3 =
     108* Minor fixes.
     109
     110= 1.0.2 =
     111* Cater for non physical goods.
    55112
    56113= 1.0.1 =
    57114* Rate card design fix.
    58115
    59 = 1.0.2 =
    60 * Cater for non physical goods.
    61 
    62 = 1.0.3 =
    63 * Minor fixes.
    64 
    65 = 1.1 =
    66 * International shipping support.
    67 
    68 = 1.3 =
    69 * Critical checkout support fix.
    70 
    71 = 1.4 =
    72 * set selected shipbubble option as checkout shipping option.
    73 
    74 = 1.5 =
    75 * Disable other shipping options option.
    76 
    77 = 1.6 =
    78 * Fixed orders page error for other shipping methods.
    79 
    80 = 1.7 =
    81 * Dimension sorting for DHL packages, Fixed some more bugs.
    82 
    83 = 1.7.1 =
    84 * Fixed checkout bug for other shipping methods (if available).
    85 
    86 = 1.7.2 =
    87 * Admin process shipment bug fix.
    88 
    89 = 1.8 =
    90 * Fixes & Improvements
    91 
    92 = 1.9 =
    93 * Important checkout UX Fix - handling when user edits checkout details.
    94 
    95 = 2.0 =
    96 * Support for non physical goods at checkout.
    97 
    98 = 2.0.1 =
    99 * Bug fix for pickup option on checkout
    100 
    101 = 2.0.2 =
    102 * Bug fix for pickup option on checkout
    103 
    104 = 2.1 =
    105 * Support for multi currency checkout
    106 
    107 = 2.2 =
    108 * Fix scenario for customers checking out without paying for delivery
    109 
    110 = 2.2.1 =
    111 * Small fix for multicurrency store symbol
    112 
    113 = 2.3 =
    114 * Handle plugin incompatibility for woocommerce block pages
     116= 0.1 =
     117* Initial release.
    115118
    116119== Upgrade Notice ==
    117 = 2.3 =
    118 Handle plugin incompatibility for woocommerce block pages
     120= 2.4 =
     121Critical checkout and backend dashboard fixes
  • shipbubble/trunk/shipbubble.php

    r3080029 r3082893  
    88 * Tags: logistics, deliveries, shipping rates, multiple couriers, post purchase experience
    99 * Requires at least: 4.0
    10  * Tested up to: 6.3
    11  * Version: 2.3
     10 * Tested up to: 6.1
     11 * Version: 2.4
    1212 * Requires PHP: 5.6
    1313 * Text Domain:  shipbubble
     
    212212    $stateTag = sanitize_text_field($_POST['shipping_state']);
    213213    $countryTag = sanitize_text_field($_POST['shipping_country']);
     214    $phone = sanitize_text_field($_POST['billing_phone']);
    214215
    215216    if (strlen($streetAddress) < 1) {
     
    263264            // setting the delivery address
    264265            update_post_meta($order_id, 'shipbubble_delivery_address', $address);
     266
     267            // setting the phone number
     268            update_post_meta($order_id, 'shipbubble_delivery_phone', $phone);
    265269        }
    266270    }
     
    268272
    269273// add_action( 'woocommerce_checkout_order_processed', 'handle_processed', 10, 1 );
    270 // function handle_processed($order_id) 
     274// function handle_processed($order_id)
    271275// {
    272276//  $order = new WC_Order( $order_id );
     
    337341
    338342add_action( 'woocommerce_before_checkout_process', 'shipbubble_validate_checkout_order' , 10, 1 );
     343add_action( 'woocommerce_checkout_order_processed', 'shipbubble_validate_checkout_order', 10, 1 );
    339344function shipbubble_validate_checkout_order($order_id)
    340345{
Note: See TracChangeset for help on using the changeset viewer.