Plugin Directory

Changeset 2883170


Ignore:
Timestamp:
03/20/2023 03:18:40 AM (3 years ago)
Author:
app360my
Message:

1.4.0

  • feature | New hook to update App360 side order status upon status changes
Location:
app360/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • app360/trunk/app360.php

    r2859516 r2883170  
    1111 * Plugin URI: https://www.app360.my/
    1212 * Description: App360 CRM allows the integration between WooCommerce and App360
    13  * Version: 1.3.15
     13 * Version: 1.4.0
    1414 * Author: App360
    1515 * License: GPLv2 or later
  • app360/trunk/readme.txt

    r2859516 r2883170  
    44Requires at least: 5.6
    55Tested up to: 5.8
    6 Stable tag: 1.3.9
     6Stable tag: 1.4.0
    77License: GPLv2 or later
    88
     
    3838
    3939== Changelog ==
     40= 1.4.0 =
     41*Release Date - 28 February 2023*
     42
     43* feature  | New hook to update App360 side order status upon status changes
    4044
    4145= 1.3.15 =
  • app360/trunk/transaction.php

    r2859500 r2883170  
    344344add_action( 'woocommerce_order_status_changed', 'app360_order_status_changed', 99, 3 );
    345345function app360_order_status_changed( $order_id, $old_status, $new_status ){
     346    $status_app360 = '';
     347    switch (strtolower($new_status)) {
     348        case 'completed':
     349            $status_app360 = 'completed';
     350            break;
     351        case 'refunded':
     352        case 'failed':
     353        case 'cancelled':
     354            $status_app360 = 'rejected';
     355            break;
     356        default:
     357            $status_app360 = 'pending';
     358    }
     359
     360    if ($status_app360 != '') {
     361        $app360_api_domain = get_option('app360_api_domain');
     362        $app360_api = get_option('app360_api');
     363        if($app360_api_domain && $app360_api){
     364            $url = $app360_api_domain.'/order/status';
     365
     366            $param = array();
     367            $param['order_id'] = $order->id;
     368            $param['source'] = 'w';
     369            $param['status'] = $status_app360;
     370
     371            $headers = array();
     372            $headers['Content-type'] = 'application/json';
     373            $headers['apikey'] = $app360_api;
     374            wp_remote_request($url, [
     375                'method' => 'PUT',
     376                'headers'=> $headers,
     377                'body' => $param
     378            ]);
     379        }
     380    }
     381
     382
    346383    if (strtolower($new_status) === 'completed') {
    347384        $order = wc_get_order( $order_id );
Note: See TracChangeset for help on using the changeset viewer.