Changeset 2545314
- Timestamp:
- 06/09/2021 09:02:57 PM (5 years ago)
- Location:
- voucherify/trunk
- Files:
-
- 7 edited
-
readme.txt (modified) (2 diffs)
-
src/class-voucherify-client-extension.php (modified) (2 diffs)
-
src/class-voucherify-order-placing-session.php (modified) (1 diff)
-
src/class-voucherify-redemption-service.php (modified) (1 diff)
-
src/class-voucherify-save-order-listener.php (modified) (1 diff)
-
src/functions.php (modified) (4 diffs)
-
voucherify.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
voucherify/trunk/readme.txt
r2529022 r2545314 7 7 WC tested up to: 4.3.1 8 8 WC requires at least: 3.0.0 9 Stable tag: 2. 1.69 Stable tag: 2.2.0 10 10 11 11 Integrates Voucherify API with woocommerce … … 49 49 50 50 == Changelog == 51 52 = 2.2.0 - 2021-06-02 = 53 * Fix: fatal error while trying to remove a coupon that does not exists in voucherify anymore 54 * Fix: Supporting PayPal IPN 51 55 52 56 = 2.1.6 - 2021-05-10 = -
voucherify/trunk/src/class-voucherify-client-extension.php
r2519268 r2545314 4 4 use Voucherify\ApiClient; 5 5 use Voucherify\VoucherifyClient; 6 use Voucherify\ClientException; 6 7 7 8 if ( ! defined( 'ABSPATH' ) ) { … … 23 24 24 25 public function release_session_lock( $code, $session_key ) { 25 return $this->client->delete( '/vouchers/' . $code . '/sessions/' . $session_key ); 26 try { 27 $this->client->delete( '/vouchers/' . $code . '/sessions/' . $session_key ); 28 } catch ( ClientException $e ) { 29 wc_get_logger()->notice( __( 'Voucher was already removed', 'voucherify' ) . PHP_EOL . 30 'original_message: ' . $e->getMessage() ); 31 } 26 32 } 27 33 } -
voucherify/trunk/src/class-voucherify-order-placing-session.php
r2529022 r2545314 197 197 198 198 foreach ( $coupons as $coupon ) { 199 $removed_coupon_idx = array_search( $coupon, WC()->session->voucherify_removed_coupons ); 199 $removed_coupons = WC()->session->voucherify_removed_coupons; 200 $removed_coupons = empty( $removed_coupons ) ? [] : $removed_coupons; 201 $removed_coupon_idx = array_search( $coupon, $removed_coupons ); 200 202 if ( ! empty( $removed_coupon_idx ) ) { 201 203 $cached_removed_vouchers = WC()->session->voucherify_removed_coupons; -
voucherify/trunk/src/class-voucherify-redemption-service.php
r2519268 r2545314 76 76 private function redeem_voucher( $code, WC_Order $order ) { 77 77 $context = apply_filters( 'voucherify_redemption_service_redemption_context', 78 vcrf_get_customer_data( ) + vcrf_get_order_data( $order ) + $this->create_session_lock_data( $order, $code ) );78 vcrf_get_customer_data( $order ) + vcrf_get_order_data( $order ) + $this->create_session_lock_data( $order, $code ) ); 79 79 80 80 $context = apply_filters( 'voucherify_redemption_service_redemption_voucher_context', $context ); 81 81 82 $this->add_shipping_to_context( $context);82 $this->add_shipping_to_context( $context ); 83 83 84 84 $response = apply_filters( 'voucherify_redemption_service_redeem', -
voucherify/trunk/src/class-voucherify-save-order-listener.php
r2529022 r2545314 269 269 $order->update_meta_data( '_voucherify_checkout_removed_coupon', $coupons_to_remove ); 270 270 } else { 271 $logger = wc_get_logger();272 $logger->error( __( 'Redeem was unsuccessful', 'voucherify' ), [ 'original_message' => $e->getMessage() ]);271 wc_get_logger()->error( __( 'Redeem was unsuccessful', 'voucherify' ) . PHP_EOL . 272 'original_message: ' . $e->getMessage() ); 273 273 throw $e; 274 274 } 275 275 } catch ( Exception $e ) { 276 $logger = wc_get_logger();277 $logger->error( __( 'Unexpected error occured', 'voucherify' ), [ 'original_message' => $e->getMessage() ]);276 wc_get_logger()->error( __( 'Unexpected error occured', 'voucherify' ) . PHP_EOL . 277 'original_message: ' . $e->getMessage() ); 278 278 throw $e; 279 279 } -
voucherify/trunk/src/functions.php
r2517898 r2545314 40 40 */ 41 41 function is_validation_blocked() { 42 $block_vouchers = is_admin() && ! ( defined( 'DOING_AJAX' ) && DOING_AJAX 43 && ! ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] === "woocommerce_refund_line_items" ) ); 42 $block_vouchers = ( is_admin() && ! ( defined( 'DOING_AJAX' ) && DOING_AJAX 43 && ! ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] === "woocommerce_refund_line_items" ) ) ) 44 || did_action( 'woocommerce_api_request' ); 44 45 45 46 return apply_filters( 'voucherify_validation_service_block_validation', $block_vouchers ); … … 164 165 * to be consumed by API. 165 166 * 167 * @param WC_Order|null $order 168 * 166 169 * @return array customer data in form of array accepted by API's context. 167 170 */ 168 function vcrf_get_customer_data( ) {171 function vcrf_get_customer_data( WC_Order $order = null ) { 169 172 if ( vcrf_is_wc_object_available() ) { 170 173 $customer_decorator = new Voucherify_Customer_Decorator( WC()->customer ); … … 173 176 } 174 177 175 /** @var WC_Order $order */ 176 $order = vcrf_get_admin_order(); 178 if ( empty( $order ) ) { 179 $order = vcrf_get_admin_order(); 180 } 181 177 182 if ( empty( $order ) ) { 178 183 return []; 179 184 } 185 180 186 $customer_data = []; 181 187 if ( ! empty( $order->get_customer_id() ) ) { 182 188 $customer_data['source_id'] = $order->get_customer_id(); 183 189 } 190 184 191 if ( ! empty( $order->get_billing_email() ) ) { 185 192 $customer_data['email'] = $order->get_billing_email(); 186 193 } 194 187 195 if ( ! empty( $order->get_formatted_billing_full_name() ) ) { 188 196 $customer_data['name'] = $order->get_formatted_billing_full_name(); 189 197 } 198 190 199 if ( empty( $customer_data ) ) { 191 200 return []; … … 207 216 } 208 217 209 if ( ! function_exists( 'vcrf_is_wc_object_available') ) {218 if ( ! function_exists( 'vcrf_is_wc_object_available' ) ) { 210 219 /** 211 220 * Checks if the default WC() object is available -
voucherify/trunk/voucherify.php
r2529022 r2545314 8 8 * Plugin URI: https://wordpress.org/plugins/voucherify/ 9 9 * Description: Integrates Voucherify API with woocommerce replacing core coupons functionality 10 * Version: 2. 1.610 * Version: 2.2.0 11 11 * Author: rspective 12 12 * Author URI: https://www.rspective.com/
Note: See TracChangeset
for help on using the changeset viewer.