From ab263d8d74ad4cfbabdd47ce254cc61ce8a6e150 Mon Sep 17 00:00:00 2001 From: Timo Janssen Date: Thu, 3 Oct 2019 14:24:15 +0200 Subject: [PATCH 1/2] add booking token import --- includes/checkout.php | 11 +++++++++++ includes/wcwuunder-create.php | 10 ++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/includes/checkout.php b/includes/checkout.php index d2d9c35..b55b326 100644 --- a/includes/checkout.php +++ b/includes/checkout.php @@ -108,6 +108,17 @@ function prefix_wc_rest_prepare_order_object( $response, $object, $request ) { } $response->data['wuunder_preferred_service_level'] = $shipping_method_id; + $bookingTokenData = get_post_meta( $object->get_id(), '_wuunder_label_booking_token' ); + + if (count($bookingTokenData)) { + $bookingToken = $bookingTokenData[0]; + } else { + $bookingToken = uniqid(); + update_post_meta( $object->get_id(), '_wuunder_label_booking_token', $bookingToken ); + } + + $response->data['wuunder_booking_token'] = $bookingToken; + return $response; } add_filter( 'woocommerce_rest_prepare_shop_order_object', 'prefix_wc_rest_prepare_order_object', 10, 3 ); diff --git a/includes/wcwuunder-create.php b/includes/wcwuunder-create.php index 931d697..2bb1b1b 100644 --- a/includes/wcwuunder-create.php +++ b/includes/wcwuunder-create.php @@ -109,9 +109,15 @@ private function wcwp_setBookingConfig($orderId ) { } $value = intval(($order->get_total() + $order->get_total_discount() - $order->get_shipping_total()) * 100); + $bookingTokenData = get_post_meta( $orderId, '_wuunder_label_booking_token' ); + + if (count($bookingTokenData)) { + $bookingToken = $bookingTokenData[0]; + } else { + $bookingToken = uniqid(); + update_post_meta( $orderId, '_wuunder_label_booking_token', $bookingToken ); + } - $bookingToken = uniqid(); - update_post_meta( $orderId, '_wuunder_label_booking_token', $bookingToken ); $redirectUrl = get_site_url( null, '/wp-admin/edit.php?post_type=shop_order' ); $webhookUrl = get_site_url( null, 'index.php/wuunder/webhook?order=' . $orderId . '&token=' . $bookingToken ); From 0dda67c91a8bca68cb72484c04562f49bcfebefd Mon Sep 17 00:00:00 2001 From: Timo Janssen Date: Mon, 7 Oct 2019 10:12:05 +0200 Subject: [PATCH 2/2] upd changelog/version --- CHANGELOG.md | 8 +++++++- includes/wcwuunder-create.php | 2 +- woocommerce-wuunder.php | 4 ++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d2105c9..d6aabe0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,13 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/). ## Released -## [2.7.5](https://github.com/kabisa/wuunder-webshopplugin-woocommerce/tag/2.7.4) - 2019-09-30 +## [2.7.6](https://github.com/kabisa/wuunder-webshopplugin-woocommerce/tag/2.7.6) - 2019-10-07 + +### Added +- Booking token support for imported orders via REST API + + +## [2.7.5](https://github.com/kabisa/wuunder-webshopplugin-woocommerce/tag/2.7.5) - 2019-09-30 ### Fixed - Parcelshop locator wuunder production settings diff --git a/includes/wcwuunder-create.php b/includes/wcwuunder-create.php index 2bb1b1b..453ae9c 100644 --- a/includes/wcwuunder-create.php +++ b/includes/wcwuunder-create.php @@ -12,7 +12,7 @@ public function __construct() { $this->version_obj = array( 'product' => 'Woocommerce extension', 'version' => array( - 'build' => '2.7.4', + 'build' => '2.7.6 ', 'plugin' => '2.0' ), 'platform' => array( 'name' => 'Woocommerce', diff --git a/woocommerce-wuunder.php b/woocommerce-wuunder.php index 18f2240..1d773aa 100644 --- a/woocommerce-wuunder.php +++ b/woocommerce-wuunder.php @@ -3,7 +3,7 @@ * Plugin Name: WooCommerce Wuunder * Plugin URI: https://wearewuunder.com/wuunder-voor-webshops/ * Description: Wuunder shipping plugin - * Version: 2.7.5 + * Version: 2.7.6 * Author: Wuunder * Author URI: http://wearewuunder.com */ @@ -57,7 +57,7 @@ class Woocommerce_Wuunder { public static $plugin_path; public static $plugin_basename; - const VERSION = '2.7.5'; + const VERSION = '2.7.6'; public function __construct() {