Plugin Directory

Changeset 2545314


Ignore:
Timestamp:
06/09/2021 09:02:57 PM (5 years ago)
Author:
rspective
Message:

Committing changes for 2.2.0

Location:
voucherify/trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • voucherify/trunk/readme.txt

    r2529022 r2545314  
    77WC tested up to: 4.3.1
    88WC requires at least: 3.0.0
    9 Stable tag: 2.1.6
     9Stable tag: 2.2.0
    1010
    1111Integrates Voucherify API with woocommerce
     
    4949
    5050== 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
    5155
    5256= 2.1.6 - 2021-05-10 =
  • voucherify/trunk/src/class-voucherify-client-extension.php

    r2519268 r2545314  
    44use Voucherify\ApiClient;
    55use Voucherify\VoucherifyClient;
     6use Voucherify\ClientException;
    67
    78if ( ! defined( 'ABSPATH' ) ) {
     
    2324
    2425        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            }
    2632        }
    2733    }
  • voucherify/trunk/src/class-voucherify-order-placing-session.php

    r2529022 r2545314  
    197197
    198198            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 );
    200202                if ( ! empty( $removed_coupon_idx ) ) {
    201203                    $cached_removed_vouchers = WC()->session->voucherify_removed_coupons;
  • voucherify/trunk/src/class-voucherify-redemption-service.php

    r2519268 r2545314  
    7676        private function redeem_voucher( $code, WC_Order $order ) {
    7777            $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 ) );
    7979
    8080            $context = apply_filters( 'voucherify_redemption_service_redemption_voucher_context', $context );
    8181
    82             $this->add_shipping_to_context($context);
     82            $this->add_shipping_to_context( $context );
    8383
    8484            $response = apply_filters( 'voucherify_redemption_service_redeem',
  • voucherify/trunk/src/class-voucherify-save-order-listener.php

    r2529022 r2545314  
    269269                    $order->update_meta_data( '_voucherify_checkout_removed_coupon', $coupons_to_remove );
    270270                } 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() );
    273273                    throw $e;
    274274                }
    275275            } 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() );
    278278                throw $e;
    279279            }
  • voucherify/trunk/src/functions.php

    r2517898 r2545314  
    4040 */
    4141function 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' );
    4445
    4546    return apply_filters( 'voucherify_validation_service_block_validation', $block_vouchers );
     
    164165     * to be consumed by API.
    165166     *
     167     * @param WC_Order|null $order
     168     *
    166169     * @return array customer data in form of array accepted by API's context.
    167170     */
    168     function vcrf_get_customer_data() {
     171    function vcrf_get_customer_data( WC_Order $order = null ) {
    169172        if ( vcrf_is_wc_object_available() ) {
    170173            $customer_decorator = new Voucherify_Customer_Decorator( WC()->customer );
     
    173176        }
    174177
    175         /** @var WC_Order $order */
    176         $order = vcrf_get_admin_order();
     178        if ( empty( $order ) ) {
     179            $order = vcrf_get_admin_order();
     180        }
     181
    177182        if ( empty( $order ) ) {
    178183            return [];
    179184        }
     185
    180186        $customer_data = [];
    181187        if ( ! empty( $order->get_customer_id() ) ) {
    182188            $customer_data['source_id'] = $order->get_customer_id();
    183189        }
     190
    184191        if ( ! empty( $order->get_billing_email() ) ) {
    185192            $customer_data['email'] = $order->get_billing_email();
    186193        }
     194
    187195        if ( ! empty( $order->get_formatted_billing_full_name() ) ) {
    188196            $customer_data['name'] = $order->get_formatted_billing_full_name();
    189197        }
     198
    190199        if ( empty( $customer_data ) ) {
    191200            return [];
     
    207216}
    208217
    209 if ( ! function_exists('vcrf_is_wc_object_available') ) {
     218if ( ! function_exists( 'vcrf_is_wc_object_available' ) ) {
    210219    /**
    211220     * Checks if the default WC() object is available
  • voucherify/trunk/voucherify.php

    r2529022 r2545314  
    88 * Plugin URI: https://wordpress.org/plugins/voucherify/
    99 * Description: Integrates Voucherify API with woocommerce replacing core coupons functionality
    10  * Version: 2.1.6
     10 * Version: 2.2.0
    1111 * Author: rspective
    1212 * Author URI: https://www.rspective.com/
Note: See TracChangeset for help on using the changeset viewer.