Plugin Directory

Changeset 2106864


Ignore:
Timestamp:
06/16/2019 09:42:22 AM (7 years ago)
Author:
mangossl
Message:

Updated to support paid and cancelled order status

Location:
mango-ssl/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • mango-ssl/trunk/mango-ssl.php

    r1859445 r2106864  
    33/**
    44 * @package mango-ssl
    5  * @version 1.0
     5 * @version 1.1
    66 */
    77/*
     
    1111Description: Mango ssl plugin sends all the order changes entered in WooCommerce to mango(www.mangossl.com) to avoid reentering those orders manually.
    1212Author: Franck Janini
    13 Version: 1.0
     13Version: 1.1
    1414Author URI: https://www.mangossl.com/
    1515*/
  • mango-ssl/trunk/mango-ssl_order.php

    r1859445 r2106864  
    1313    add_action('woocommerce_order_status_changed', 'mango_ssl_update', 10, 1);
    1414   
     15    add_action( 'woocommerce_payment_complete', 'mango_ssl_payment_complete' );
     16   
     17    add_action( 'woocommerce_order_status_cancelled', 'mango_ssl_cancel', 10, 1 );
     18   
    1519// mango_ssl_update creates a mango order class from a woocommerce order change and sends it to mango
    1620
    1721    function mango_ssl_update($order_id)
    1822    {
    19        
    2023        error_log("Order has been updated $order_id");
    2124       
    2225        global $woocommerce;
    2326        $order = wc_get_order( $order_id );
    24         $obj = new mango_ssl_order($order);
     27        $obj = new mango_ssl_order($order,'update');
     28       
     29        $mango = new mango_ssl_call();
     30        $mango->send('save','COMMAND',$obj);
     31    }
     32   
     33    function mango_ssl_cancel( $order_id )
     34    {
     35        error_log("Order has been canceled $order_id");
     36       
     37        global $woocommerce;
     38        $order = wc_get_order( $order_id );
     39        $obj = new mango_ssl_order($order,'cancel');
     40       
     41        $mango = new mango_ssl_call();
     42        $mango->send('save','COMMAND',$obj);
     43    }
     44   
     45    function mango_ssl_payment_complete( $order_id )
     46    {
     47        error_log("Order has been payed $order_id");
     48       
     49        global $woocommerce;
     50        $order = wc_get_order( $order_id );
     51        $obj = new mango_ssl_order($order,'paid');
    2552       
    2653        $mango = new mango_ssl_call();
     
    136163        var $date;
    137164        var $type;
    138         var $status;
     165        var $status;
     166        var $message;
     167        var $system_status;
    139168        var $currency;
    140169        var $payment_method;
     
    146175        var $detail = array();
    147176       
    148         public function __construct($woo_order)
     177        public function __construct($woo_order,$message)
    149178        {
    150179            $order_data = $woo_order->get_data();
     
    155184            $this->po = $order_data['parent_id'];
    156185           
    157             if ($order_data['status']=='on-hold')
    158                 $this->status = 'HOLD';
    159             else if ($order_data['status']=='processing')
    160                 $this->status = 'COMMIT';
    161             else if ($order_data['status']=='completed')
    162                 $this->status = 'COMMIT';
    163             else
    164                 $this->status = 'HOLD';
     186            $this->message = $message;
     187            $this->system_status = $order_data['status'];
     188           
     189            if ($message=='update')
     190            {
     191                if ($order_data['status']=='on-hold')
     192                    $this->status = 'HOLD';
     193                else if ($order_data['status']=='processing')
     194                    $this->status = 'COMMIT';
     195                else if ($order_data['status']=='completed')
     196                    $this->status = 'COMMIT';
     197                else if ($order_data['status']=='cancelled')
     198                    $this->status = 'CANCELLED';
     199                else
     200                    $this->status = 'HOLD';
     201            }
     202            else if ($message=='paid')
     203            {
     204                $this->status = 'PAID';
     205            }
     206            else if ($message=='cancel')
     207            {
     208                $this->status = 'CANCELLED';
     209            }
    165210
    166211            $this->currency = $order_data['currency'];
  • mango-ssl/trunk/readme.txt

    r1859445 r2106864  
    88Tags: accounting, inventory, payment
    99Requires at least: 4.6
    10 Tested up to: 4.9.4
     10Tested up to: 5.2.1
    1111Requires WooCommerce 3 or higher
    1212Stable tag: trunk
     
    6969* Fist release
    7070
     71= 1.1 =
     72* Updated to support paid and cancelled order status
     73
    7174== Upgrade Notice ==
    7275
     
    7477First release
    7578
    76 
     79= 1.1 =
     80* Updated to support paid and cancelled order status
Note: See TracChangeset for help on using the changeset viewer.