Skip to content

Commit

Permalink
Merge pull request #5 from Codaone/webhook
Browse files Browse the repository at this point in the history
Webhook
  • Loading branch information
mikakoi authored Mar 16, 2017
2 parents e4efdc2 + cf22747 commit 7708d3c
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions logitrail-woocommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,7 @@ public function __construct() {
add_filter( 'woocommerce_shipping_methods', array( $this, 'logitrail_add_method') );

add_action( 'woocommerce_checkout_shipping', array($this, 'logitrail_get_template') );
add_action( 'woocommerce_payment_complete', array($this, 'logitrail_payment_complete'), 10, 1 );

add_action( 'woocommerce_order_status_completed', array($this, 'logitrail_payment_complete'), 10, 1 );
add_action( 'woocommerce_thankyou', array($this, 'logitrail_payment_complete'), 10, 1 );

add_action( 'wc_ajax_logitrail', array($this, 'logitrail_get_form' ) );
add_action( 'wc_ajax_logitrail_setprice', array($this, 'logitrail_set_price'));
Expand Down Expand Up @@ -115,7 +113,7 @@ public function validate_shipping_method($data = '') {
}
}

/**
/**
* Add new endpoints.
*/
public static function add_endpoint() {
Expand Down Expand Up @@ -272,10 +270,10 @@ public function logitrail_get_form() {
$form = $apic->getForm();
}
if ($shipping_count > 0) {
set_transient('logitrail_shipping', true);
set_transient('logitrail_' . $woocommerce->session->get_session_cookie()[3] . '_shipping', true);
echo $form;
} else {
set_transient('logitrail_shipping', false);
set_transient('logitrail_' . $woocommerce->session->get_session_cookie()[3] . '_shipping', false);
}


Expand Down Expand Up @@ -887,6 +885,11 @@ function update_product() {
wc_update_product_stock($product['merchants_id'], $product['inventory']['available']);
}
break;
case "order.shipped":
$order_id = $received_data['merchants_id'];
$order = new WC_Order($order_id);
$order->update_status('completed');
break;
}
}
}
Expand Down

0 comments on commit 7708d3c

Please sign in to comment.