Plugin Directory

Changeset 2973326


Ignore:
Timestamp:
09/30/2023 12:01:48 PM (2 years ago)
Author:
shipbubble
Message:

Fixed orders page error for other shipping methods

Location:
shipbubble
Files:
45 added
4 edited

Legend:

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

    r2972632 r2973326  
    88    }
    99
     10    // Verify Shipbubble Order
     11    if (!$order->has_shipping_method(SHIPBUBBLE_ID)) {
     12        return;
     13    }
     14
     15    $shipmentDetailsArray = get_post_meta($order->get_id(), 'shipbubble_shipment_details');
     16    // error_log(print_r($shipmentDetailsArray, true));
     17    if (!count($shipmentDetailsArray)) {
     18        return;
     19    }
     20
     21    // Get Shipping Data
    1022    $shippingData = $order->data['shipping'];
    1123    $orderAddress = sb_create_address($shippingData['address_1'], $shippingData['city'], $shippingData['state'], $shippingData['country']);
     
    1830    // die;
    1931
     32    // Get Delivery Address
    2033    $shipbubbleDeliveryAddress = get_post_meta($order->get_id(), 'shipbubble_delivery_address', true);
    2134
     35    // Get Shipbubble Order ID
    2236    $shipbubbleOrderId = get_post_meta($order->get_id(), 'shipbubble_order_id', true);
    2337
    24     if (!count(get_post_meta($order->get_id(), 'shipbubble_shipment_details'))) {
    25         return;
    26     }
    27 
    28     $shipment = get_post_meta($order->get_id(), 'shipbubble_shipment_details')[0];
    29 
     38    $shipment = $shipmentDetailsArray[0]; // [0 => 'request token ...']
    3039
    3140    // $serviceCode = array( 'speedaf-express' ); // test
     
    6473    }
    6574
    66     $orderShippingMethodId = reset($order->get_items('shipping'))->get_method_id();
    67 
    6875?>
    69     <?php if (strlen($shipbubbleOrderId) < 1 && !is_null($shipment) && (strtolower($orderShippingMethodId) === strtolower(SHIPBUBBLE_ID))) : ?>
     76    <?php if (strlen($shipbubbleOrderId) < 1 && !is_null($shipment)) : ?>
    7077        <input type="hidden" id="wc_order_id" name="wc_order_id" value='<?php echo esc_html($order->get_id()); ?>' />
    7178
     
    8188
    8289
    83 add_filter('manage_edit-shop_order_columns', 'shipbubble_custom_order_column', 20);
     90add_filter('manage_edit-shop_order_columns', 'shipbubble_custom_order_column', 10);
    8491function shipbubble_custom_order_column($columns)
    8592{
     
    9097        if ($key == 'order_status') {
    9198            // Inserting after STATUS Column
    92             $reorderedColumns['sb_shipping_status'] = esc_html('Shipbubble Status');
     99            $reorderedColumns['sb_shipping_status'] = esc_html('Shipping Status');
    93100        }
    94101    }
     
    97104}
    98105
    99 // Adding custom fields meta data for each new Column
    100 add_action('manage_shop_order_posts_custom_column', 'custom_orders_list_column_content', 20, 2);
    101 function custom_orders_list_column_content($column, $post_id)
    102 {
    103     $order = wc_get_order($post_id);
    104     $orderShippingMethod = $order->get_items('shipping');
    105     $orderShippingMethodId = '';
    106 
    107     switch ($column) {
    108         case 'sb_shipping_status':
    109             if (is_array($orderShippingMethod)) {
    110                 $orderShippingMethodId = reset($orderShippingMethod)->get_method_id();
     106add_action('manage_shop_order_posts_custom_column', 'shipbubble_shipping_status_column_content');
     107function shipbubble_shipping_status_column_content($column)
     108{
     109    global $post;
     110
     111    // Verify Column ID
     112    if ('sb_shipping_status' === $column) {
     113        // Get Order
     114        $order = new WC_Order($post->ID);
     115
     116        // Conditional function based on the Order shipping method
     117        if ($order->has_shipping_method(SHIPBUBBLE_ID)) {
     118            // Check Shipping Status
     119            $status = get_post_meta($post->ID, 'shipbubble_tracking_status', true);
     120            if (!empty($status)) {
     121                echo shipbubble_shipment_status_label($status);
     122            } elseif (in_array($order->get_status(), SHIPBUBBLE_WC_BAD_ORDER_STATUS_ARR)) {
     123                echo '<mark class="order-status status-on-hold">
     124                        <span>No shipment initiated</span>
     125                    </mark>';
     126            } else {
     127                echo '<mark class="order-status status-on-hold">
     128                        <span>No shipment yet</span>
     129                    </mark>';
    111130            }
    112 
    113             if (!empty($orderShippingMethodId) && strtolower($orderShippingMethodId) === strtolower(SHIPBUBBLE_ID)) {
    114                 $status = get_post_meta($post_id, 'shipbubble_tracking_status', true);
    115                 if (!empty($status)) {
    116                     echo shipbubble_shipment_status_label($status);
    117                 } elseif (in_array($order->get_status(), SHIPBUBBLE_WC_BAD_ORDER_STATUS_ARR)) {
    118                     echo '<mark class="order-status status-on-hold">
    119                             <span>No shipment initiated</span>
    120                         </mark>';
    121                 } else {
    122                     echo '<mark class="order-status status-on-hold">
    123                             <span>No shipment yet</span>
    124                         </mark>';
    125                 }
    126             } elseif (!empty($orderShippingMethodId)) {
    127                 echo esc_html($order->get_shipping_method());
    128             } else {
    129                 echo esc_html('Not Specified');
    130             }
    131 
    132             break;
     131        } elseif (!$order->has_shipping_method(SHIPBUBBLE_ID)) {
     132            echo 'N/A';
     133        } else {
     134            echo esc_html('Not specified');
     135        }
    133136    }
    134137}
     
    244247    // $shipbubbleOrderId = get_post_meta( $order->get_id(), 'shipping_total', true );
    245248
    246     if (in_array($order->get_status(), SHIPBUBBLE_WC_BAD_ORDER_STATUS_ARR))
    247         return;
     249    if (in_array($order->get_status(), SHIPBUBBLE_WC_BAD_ORDER_STATUS_ARR)) {
     250        return;
     251    }
     252
     253    // Verify Shipbubble Order
     254    if (!$order->has_shipping_method(SHIPBUBBLE_ID)) {
     255        return;
     256    }
    248257
    249258    if (!count(get_post_meta($order->get_id(), 'shipbubble_shipment_details'))) {
     
    251260    }
    252261
    253     $orderShippingMethodId = reset($order->get_items('shipping'))->get_method_id();
    254 
    255     if (strtolower($orderShippingMethodId) === strtolower(SHIPBUBBLE_ID)) {
    256         $shipbubbleOrderId = get_post_meta($order->get_id(), 'shipbubble_order_id', true);
    257 
    258         if (strlen($shipbubbleOrderId) < 1) {
    259             $response = shipbubble_get_wallet_balance(shipbubble_get_token());
    260 
    261             if (isset($response->response_code) && $response->response_code == SHIPBUBBLE_RESPONSE_IS_OK) {
    262                 $balance = $response->data->balance;
    263             }
    264 
    265             echo '<input type="hidden" id="shipbubble_shipping_cost" name="shipbubble_shipping_cost" value="' . esc_html((float) $order->shipping_total) . '"/>';
    266 
    267             echo '<input type="hidden" id="shipbubble_wallet_balance" name="shipbubble_wallet_balance" value="' . esc_html((float) $balance) . '"/>';
    268 
    269             echo '<p><strong>' . __('Shipbubble Wallet Balance:') . '</strong><br> <strong>' . esc_html($currency) . esc_html(number_format($balance, 2)) . '</strong></p>';
    270         } else {
    271             echo '<p><strong>' . __('Shipbubble Order ID:') . '</strong><br> ' . esc_html($shipbubbleOrderId) . '</p>';
    272         }
    273     }
    274 }
     262    $shipbubbleOrderId = get_post_meta($order->get_id(), 'shipbubble_order_id', true);
     263    if (strlen($shipbubbleOrderId) < 1) {
     264        $response = shipbubble_get_wallet_balance(shipbubble_get_token());
     265
     266        if (isset($response->response_code) && $response->response_code == SHIPBUBBLE_RESPONSE_IS_OK) {
     267            $balance = $response->data->balance;
     268        }
     269
     270        echo '<input type="hidden" id="shipbubble_shipping_cost" name="shipbubble_shipping_cost" value="' . esc_html((float) $order->shipping_total) . '"/>';
     271
     272        echo '<input type="hidden" id="shipbubble_wallet_balance" name="shipbubble_wallet_balance" value="' . esc_html((float) $balance) . '"/>';
     273
     274        echo '<p><strong>' . __('Shipbubble Wallet Balance:') . '</strong><br> <strong>' . esc_html($currency) . esc_html(number_format($balance, 2)) . '</strong></p>';
     275    } else {
     276        echo '<p><strong>' . __('Shipbubble Order ID:') . '</strong><br> ' . esc_html($shipbubbleOrderId) . '</p>';
     277    }
     278}
  • shipbubble/trunk/public/css/styles-wc.css

    r2922553 r2973326  
    1 .container-card>button {
    2     background: #D83854;
    3     outline: none;
    4     border-radius: 8px;
    5     border: none;
    6     box-shadow: none;
    7     cursor: pointer;
    8     padding: 10px 16px;
    9 
    10     margin-bottom: 24px;
    11 }
    12 
    13 .container-delivery-card-list-item:last-of-type {
    14     margin: 0;
    15 }
    16 
    17 .container-card>button>p {
    18     font-weight: 400;
    19     font-size: 16px;
    20     line-height: 20px;
    21     margin: 0;
    22     color: #FFFFFF;
    23 }
    24 
    25 .container-delivery-card {
    26     background: white;
    27     width: 100%;
    28     max-width: 549px;
    29     border-radius: 12px
    30 }
    31 
    32 .container-delivery-card-header {
    33     display: flex;
    34     margin-bottom: 24px;
    35     justify-content: space-between;
    36     align-items: center;
    37 }
    38 
    39 .container-delivery-card-header>p {
    40     font-weight: 700;
    41     font-size: 16px;
    42     line-height: 24px;
    43     color: #000000;
    44     margin: 0;
    45 }
    46 
    47 .sb-slogan-container {
    48     display: flex;
    49     align-items: center;
    50     justify-content: center;
    51     margin-top: 12px;
    52 }
    53 
    54 .sb-slogan {
    55     display: inline-flex;
    56     text-decoration: none !important;
    57     border-radius: 8px;
    58     padding: 8px 12px;
    59     align-items: center;
    60     cursor: pointer;
    61 }
    62 
    63 .sb-slogan>span {
    64     font-weight: 400;
    65     font-size: 11px;
    66     line-height: 16px;
    67     margin: 0;
    68     color: #000;
    69     margin-right: 8px;
    70 }
    71 
    72 .sb-slogan>img {
    73     max-height: 16px;
    74 }
    75 
    761.container-card>button {
    772    font-weight: 400;
     
    8510    padding: 10px 16px;
    8611    margin-bottom: 24px;
    87     width: 170px;
    8812    height: 40px;
     13    outline: none;
     14    cursor: pointer;
     15}
     16
     17.container-delivery-card-list-item:last-of-type {
     18    margin: 0;
     19}
     20
     21.container-card>button>p {
     22    font-weight: 400;
     23    font-size: 16px;
     24    line-height: 20px;
     25    margin: 0;
     26    color: #FFFFFF;
     27}
     28
     29.container-delivery-card {
     30    background: white;
     31    width: 100%;
     32    max-width: 549px;
     33    border-radius: 12px
     34}
     35
     36.container-delivery-card-header {
     37    display: flex;
     38    margin-bottom: 24px;
     39    justify-content: space-between;
     40    align-items: center;
     41}
     42
     43.container-delivery-card-header>p {
     44    font-weight: 700;
     45    font-size: 16px;
     46    line-height: 24px;
     47    color: #000000;
     48    margin: 0;
     49}
     50
     51.sb-slogan-container {
     52    display: flex;
     53    align-items: center;
     54    justify-content: center;
     55    margin-top: 12px;
     56}
     57
     58.sb-slogan {
     59    display: inline-flex;
     60    text-decoration: none !important;
     61    border-radius: 8px;
     62    padding: 8px 12px;
     63    align-items: center;
     64    cursor: pointer;
     65}
     66
     67.sb-slogan>span {
     68    font-weight: 400;
     69    font-size: 11px;
     70    line-height: 16px;
     71    margin: 0;
     72    color: #000;
     73    margin-right: 8px;
     74}
     75
     76.sb-slogan>img {
     77    max-height: 16px;
    8978}
    9079
  • shipbubble/trunk/readme.txt

    r2972632 r2973326  
    55Requires at least: 4.0
    66Tested up to: 6.3
    7 Stable tag: 1.5.1
     7Stable tag: 1.6
    88Requires PHP: 5.6
    99License: GPLv3 or later
     
    7575* Disable other shipping options option.
    7676
     77= 1.6 =
     78* Fixed orders page error for other shipping methods.
     79
    7780== Upgrade Notice ==
    78 = 1.3 =
    79 Upgrade plugin to get fix on after payment checkout support
     81= 1.6 =
     82Fixed orders page error for other shipping methods
  • shipbubble/trunk/shipbubble.php

    r2972632 r2973326  
    99 * Requires at least: 4.0
    1010 * Tested up to: 6.3
    11  * Version: 1.5.1
     11 * Version: 1.6
    1212 * Requires PHP: 5.6
    1313 * Text Domain:  shipbubble
Note: See TracChangeset for help on using the changeset viewer.