Plugin Directory

Changeset 2426319


Ignore:
Timestamp:
11/26/2020 07:20:49 AM (5 years ago)
Author:
hubbedwordpress
Message:

Consignment call on Createorder instead of fulfillment.

Location:
hubbed
Files:
48 added
1 deleted
2 edited

Legend:

Unmodified
Added
Removed
  • hubbed/trunk/assets/admin/script.js

    r2399478 r2426319  
    113113
    114114// Generate Tracking No. and Consignment no.
    115 
     115/*
    116116jQuery('#hubbed_order_fullfill_button').on("click", function() {
    117117var hubbed_enable_order_id = jQuery('#hubbed_enable_order_id').val();
     
    147147
    148148 });
     149*/
    149150
    150151// Hubbed Price change
  • hubbed/trunk/hubbed.php

    r2413241 r2426319  
    44Plugin URI: https://hubbed.com.au
    55Description: HUBBED has developed a number of technology solutions that allow carriers and merchants to seamlessly integrate into the HUBBED collection point networks, and deliver various services to the delight of their customers.
    6 Version: 2.2
     6Version: 2.3
    77Author: HUBBED
    88Author URI: http://hubbed.com.au/
    99*/
    1010if ( ! defined( 'ABSPATH' ) ) exit;
     11
    1112define('HUBBED_APP_URL', 'https://apps.hubbed.com.au');
    1213define('HUBBED_CLIENT_API_URL', 'https://production-api.hubbed.com.au/v1/');
    1314define('HUBBED_WEB_URL', 'https://clickandcollect.hubbed.com/wp-json/hubbedzohoapi/v1/');
     15
    1416define('Hubbed_API_URL', HUBBED_APP_URL.'/api');
    1517define('Hubbed_DIR', plugin_dir_path(__FILE__));
     
    154156        }
    155157        require_once 'includes/search_list.php';
    156         require_once 'includes/order-post.php';
     158       
    157159
    158160
     
    330332        global $wpdb;
    331333        session_start();
     334        $hubbed_id = "";
    332335        $user_id = get_current_user_id();
    333336        if(isset($_POST['hubbed_checkout_address_feild']) && !empty($_POST['hubbed_checkout_address_feild']))
    334337        {
     338
     339            $articles = array();
     340              $count = 0;
     341              $order = wc_get_order( $order_id );
     342              foreach ( $order->get_items() as $item )
     343              {
     344                $product_id = absint($item['product_id']);
     345                $product = wc_get_product( $product_id );
     346                $productweight = $product->get_weight();
     347                $weight = 1;
     348                if ( empty($productweight) or $productweight < 1)
     349                 {
     350                  $weight = 1;
     351                  }else{
     352                    $weight = $product->get_weight();
     353                  }
     354                  $sku = $product->get_sku();
     355                  if(empty($sku)){
     356                  $sku = $product->get_id();
     357                  }
     358                $articles[$count]["barcode"] = ($sku.'_'.get_post_meta( $hubbed_enable_order_id, 'hubbed_client_id', true ));
     359                $articles[$count]["volume"]= (($item ->get_quantity() != null) ? $item ->get_quantity() : '');
     360                $articles[$count]["weight"]= $weight;
     361                $count++;
     362              }
     363
    335364    //$hubbed_address = $_SESSION['hubbed_selectaddress'];
    336365
     
    386415            $gethubbedid = json_decode($body, true);
    387416            $hubbed_id = $gethubbedid['result']['success']['hubbed_id'];
    388 
     417            update_post_meta( $order_id, 'hubbed_consignment_no',$hubbed_id);
     418           
    389419            if (empty($hubbed_id)) {
    390420                $response = wp_remote_get($path2, $apidata1);
     
    412442            }
    413443           
    414             update_post_meta($order_id,'_shipping_company',$_SESSION['hubbed_company'] . " - HUBBED");
     444            update_post_meta($order_id,'_shipping_company',$_SESSION['hubbed_company']);
    415445            update_post_meta($order_id,'_shipping_address_1',$_SESSION['hubbed_address']);
    416446            update_post_meta($order_id,'_shipping_city',$_SESSION['hubbed_city']);
     
    460490            }else{ $hubbed_city = $_SESSION['hubbed_city']; }
    461491
    462             $hubbed_address = $firstname.' '.$lastname.'|'.$_SESSION['hubbed_company'].' - HUBBED |'.$hubbed_street.'|'.$hubbed_city.' , '.$_SESSION['hubbed_state'].'|'.$_SESSION['hubbed_country'].' , '. $_SESSION['hubbed_zip'];
     492            $hubbed_address = $firstname.' '.$lastname.'|'.$_SESSION['hubbed_company'].'|'.$hubbed_street.'|'.$hubbed_city.' , '.$_SESSION['hubbed_state'].'|'.$_SESSION['hubbed_country'].' , '. $_SESSION['hubbed_zip'];
    463493
    464494
     
    495525            $passdata['hubbedid'] = $hubbed_id;
    496526            $passdata['storedlb'] = $hubbed_hubbedlb;
     527            $passdata['articles'] = ((isset($articles) && $articles != null) ? $articles : []);
    497528            $body = hubbed_api_call('/order/create', $passdata);
    498529            update_post_meta($order_id ,'error',$body);
     530            if (isset($body['result'][0]) && $body['result'][0]['responseCode'] == 200 )
     531            {
     532                update_post_meta( $order_id, 'hubbed_consignment_status','success');
     533            }
     534            else
     535            {
     536                update_post_meta( $order_id, 'hubbed_consignment_status','error');
     537               
     538            }
     539           
    499540        }
    500541
Note: See TracChangeset for help on using the changeset viewer.