Plugin Directory

Changeset 3145874


Ignore:
Timestamp:
09/03/2024 10:28:56 AM (17 months ago)
Author:
revolutbusiness
Message:

Update plugin sources to version 4.17.2

Location:
revolut-gateway-for-woocommerce/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • revolut-gateway-for-woocommerce/trunk/gateway-revolut.php

    r3143027 r3145874  
    77 * Author URI: https://www.revolut.com/business/online-payments
    88 * Text Domain: revolut-gateway-for-woocommerce
    9  * Version: 4.17.1
     9 * Version: 4.17.2
    1010 * Requires at least: 4.4
    1111 * Tested up to: 6.5.4
     
    1616defined( 'ABSPATH' ) || exit;
    1717define( 'REVOLUT_PATH', plugin_dir_path( __FILE__ ) );
    18 define( 'WC_GATEWAY_REVOLUT_VERSION', '4.17.1' );
     18define( 'WC_GATEWAY_REVOLUT_VERSION', '4.17.2' );
    1919define( 'WC_GATEWAY_PUBLIC_KEY_ENDPOINT', '/public-key/latest' );
    2020define( 'WC_GATEWAY_REVPAY_INDEX', 'USE_REVOLUT_PAY_2_0' );
  • revolut-gateway-for-woocommerce/trunk/includes/abstract/class-wc-payment-gateway-revolut.php

    r3142952 r3145874  
    9292        add_action( 'add_option_woocommerce_revolut_settings', array( $this, 'request_available_payment_methods_and_brand_logos' ) );
    9393        add_action( 'update_option_woocommerce_revolut_settings', array( $this, 'request_available_payment_methods_and_brand_logos' ) );
    94         add_action( 'added_post_meta', array( $this, 'save_shipments_information' ), 10, 4 );
    95         add_action( 'added_order_meta', array( $this, 'save_shipments_information' ), 10, 4 );
    96         add_action( 'updated_post_meta', array( $this, 'save_shipments_information' ), 10, 4 );
    97         add_action( 'updated_order_meta', array( $this, 'save_shipments_information' ), 10, 4 );
     94        add_action( 'woocommerce_update_order', array( $this, 'save_shipments_information' ), 10, 1 );
    9895    }
    9996
     
    110107            $shipments        = array(
    111108                array(
    112                     'tracking_number'  => $tracking_item['tracking_number'],
    113                     'shipping_company' => $tracking_item['tracking_provider'],
     109                    'tracking_number'       => $tracking_item['tracking_number'],
     110                    'shipping_company_name' => $tracking_item['tracking_provider'],
    114111                ),
    115112            );
     
    124121     * Fires immediately after updating metadata.
    125122     *
    126      * @param int    $meta_id    ID of updated metadata entry.
    127      * @param int    $order_id   Order Object ID.
    128      * @param string $meta_key   Metadata key.
    129      * @param mixed  $meta_value Metadata value.
    130      */
    131     public function save_shipments_information( $meta_id, $order_id = 0, $meta_key = '', $meta_value = '' ) {
     123     * @param int $order_id Order Object ID.
     124     */
     125    public function save_shipments_information( $order_id = 0 ) {
    132126        try {
    133             if ( ! $order_id || ( strpos( $meta_key, 'tracking_code' ) === false && strpos( $meta_key, 'tracking_number' ) === false && strpos( $meta_key, 'tracking_provider' ) === false ) ) {
    134                 return;
    135             }
    136 
    137127            $wc_order                = wc_get_order( $order_id );
    138128            $revolut_order_id        = $wc_order->get_meta( 'revolut_payment_order_id', true );
     
    143133            }
    144134
    145             if ( strpos( $meta_key, 'tracking_number' ) !== false ) {
    146                 $shipping_company = $this->get_order_meta_by_partial_key( $wc_order, 'shipping_company' );
    147                 $tracking_number  = $meta_value;
    148             }
    149 
    150             if ( strpos( $meta_key, 'tracking_code' ) !== false ) {
    151                 $shipping_company = $this->get_order_meta_by_partial_key( $wc_order, 'shipping_company' );
    152                 $tracking_number  = $meta_value;
    153             }
    154 
    155             if ( strpos( $meta_key, 'tracking_provider' ) !== false ) {
    156                 $shipping_company = $meta_value;
    157                 $tracking_number  = $this->get_order_meta_by_partial_key( $wc_order, 'tracking_number' );
    158             }
     135            $shipping_company = $this->get_order_meta_by_partial_key( $wc_order, array( 'shipping_company', 'shipping_provider', 'tracking_provider' ) );
     136            $tracking_number  = $this->get_order_meta_by_partial_key( $wc_order, array( 'tracking_number', 'tracking_code' ) );
    159137
    160138            if ( empty( $shipping_company ) || empty( $tracking_number ) ) {
     
    166144            $shipping['shipments'] = array(
    167145                array(
    168                     'tracking_number'  => $tracking_number,
    169                     'shipping_company' => $shipping_company,
     146                    'tracking_number'       => $tracking_number,
     147                    'shipping_company_name' => $shipping_company,
    170148                ),
    171149            );
    172150
    173             $this->api_client->patch( "/orders/$revolut_order_id", $shipping, false, true );
     151            $order_details = array( 'shipping' => $shipping );
     152
     153            $this->api_client->patch( "/orders/$revolut_order_id", $order_details, false, true );
    174154
    175155            $wc_order->update_meta_data( 'is_rev_shipments_info_saved', true );
  • revolut-gateway-for-woocommerce/trunk/includes/traits/wc-revolut-helper-trait.php

    r3143027 r3145874  
    170170     */
    171171    public function collect_order_shipping_info( $order ) {
    172         $shipping_address = $order->get_address( 'shipping' );
     172        $shipping_address     = $order->get_address( 'shipping' );
     173        $billing_phone_number = preg_replace( '/[^0-9]/', '', $order->get_billing_phone() );
    173174
    174175            $shipping = array(
     
    184185                    'name'  => $shipping_address['first_name'] . ' ' . $shipping_address['last_name'],
    185186                    'email' => $order->get_billing_email(),
    186                     'phone' => $order->get_billing_phone(),
     187                    'phone' => empty( $billing_phone_number ) ? null : $billing_phone_number,
    187188                ),
    188189            );
     
    215216            $product_url       = get_permalink( $product_id );
    216217            $image_urls        = $this->get_product_images( $product );
     218
     219            if ( ! empty( $description ) && strlen( $description ) > 1024 ) {
     220                $description = substr( $description, 0, 1024 );
     221            }
    217222
    218223            $line_items[] = array(
     
    11081113     *
    11091114     * @param object $order WC Order object.
    1110      * @param string $meta_key ket of meta data.
    1111      */
    1112     public function get_order_meta_by_partial_key( $order, $meta_key ) {
     1115     * @param array  $metakey_list key of meta data.
     1116     */
     1117    public function get_order_meta_by_partial_key( $order, $metakey_list ) {
    11131118        foreach ( $order->get_meta_data() as $meta ) {
    1114             if ( strpos( $meta->key, $meta_key ) !== false ) {
    1115                 return $meta->value;
     1119            foreach ( $metakey_list as $meta_key ) {
     1120                if ( strpos( $meta->key, $meta_key ) !== false ) {
     1121                    return $meta->value;
     1122                }
    11161123            }
    11171124        }
  • revolut-gateway-for-woocommerce/trunk/readme.txt

    r3143027 r3145874  
    44Requires at least: 4.4
    55Tested up to: 6.5
    6 Stable tag: 4.17.1
     6Stable tag: 4.17.2
    77Requires PHP: 7.0
    88License: GPLv2 or later
     
    9999
    100100== Changelog ==
     101= 4.17.2 =
     102* Added logic for collecting line items & proof of shipping
     103
    101104= 4.17.1 =
    102105* Fixed Woo Blocks order processing
Note: See TracChangeset for help on using the changeset viewer.