Plugin Directory

Changeset 2853863


Ignore:
Timestamp:
01/24/2023 06:33:55 PM (3 years ago)
Author:
shadim
Message:

Tagging version 1.3.4

Location:
faire-for-woocommerce
Files:
11 edited
2 copied

Legend:

Unmodified
Added
Removed
  • faire-for-woocommerce/tags/1.3.4/faire-for-woocommerce.php

    r2849950 r2853863  
    55 * Author: Faire
    66 * Author URI: https://faire.com/
    7  * Version: 1.3.2
     7 * Version: 1.3.4
    88 *
    99 * This program is free software: you can redistribute it and/or modify
     
    2929}
    3030
    31 const VERSION = '1.3.2';
     31const VERSION = '1.3.4';
    3232
    3333if ( ! defined( 'FAIRE_WC_PLUGIN_FILE' ) ) {
  • faire-for-woocommerce/tags/1.3.4/readme.txt

    r2849951 r2853863  
    44Requires at least: 4.7
    55Tested up to: 6.0
    6 Stable tag: 1.3.2
     6Stable tag: 1.3.3
    77Requires PHP: 7.4
    88WC requires at least: 6.0
     
    6464
    6565This is likely because products have not been synced or linked.
    66 If you’d like to sync new products from WooCommerce to Faire, you can do that by following the steps in the help center. If you have existing products on Faire, you can link the existing products to products in WooCommerce following the steps in the help center. 
     66If you’d like to sync new products from WooCommerce to Faire, you can do that by following the steps in the help center. If you have existing products on Faire, you can link the existing products to products in WooCommerce following the steps in the help center.
    6767
    6868= Can I only sync inventory? =
    6969
    70 Yes - you can choose to only sync inventory from WooCommerce to Faire. 
     70Yes - you can choose to only sync inventory from WooCommerce to Faire.
    7171I don’t want to sync all product details from WooCommerce to Faire (I use different images/prices/etc)
    7272You have the ability to select any details you wouldn’t like to sync over by adding them to the ‘exclude sync fields’ settings on WooCommerce. This will prevent those details from being overwritten on Faire with details from WooCommerce.
    7373
    7474== Changelog ==
     75
     76= 1.3.4 =
     77* Fixed orders sync should import orders 30 days back only first time.
     78* Fixed Faire orders should be skipped, synced or updated depending on status.
     79
     80= 1.3.3 =
     81* Added case sizing fields to products
    7582
    7683= 1.3.2 =
  • faire-for-woocommerce/tags/1.3.4/src/admin/class-wc-integration-faire.php

    r2838583 r2853863  
    430430                    'product.allow_sales_when_out_of_stock' => __( 'Allow Sales When Out Of Stock', 'faire-for-woocommerce' ),
    431431                    'product.preorder_fields' => __( 'Product Preorder fields', 'faire-for-woocommerce' ),
     432          'product.unit_multiplier' => __( 'Case quantity', 'faire-for-woocommerce' ),
     433          'product.minimum_order_quantity' => __( 'Minimum order quantity', 'faire-for-woocommerce' ),
     434          'product.per_style_minimum_order_quantity' => __( 'Per style minimum order quantity', 'faire-for-woocommerce' ),
    432435                    'variant.sku'             => __( 'Variant SKU', 'faire-for-woocommerce' ),
    433436                    'variant.tariff_code'     => __( 'Variant Tariff Code', 'faire-for-woocommerce' ),
  • faire-for-woocommerce/tags/1.3.4/src/admin/product/class-product.php

    r2838583 r2853863  
    129129        echo '</div>';
    130130        echo '</div>';
     131    echo '<div class="options_group show_if_simple show_if_variable">';
     132        woocommerce_wp_text_input(
     133            array(
     134                'id'                => self::PRODUCT_FIELDS_PREFIX . 'unit_multiplier',
     135                'label'             => __( 'Case quantity (Faire)', 'faire-for-woocommerce' ),
     136                'type'                => 'number',
     137        'default'           => '1',
     138        'custom_attributes' => array(
     139                    'min'  => '1',
     140                    'step' => '1',
     141                ),
     142            )
     143        );
     144    woocommerce_wp_text_input(
     145            array(
     146                'id'                => self::PRODUCT_FIELDS_PREFIX . 'minimum_order_quantity',
     147                'label'             => __( 'Minimum order quantity (Faire)', 'faire-for-woocommerce' ),
     148                'type'                => 'number',
     149        'custom_attributes' => array(
     150                    'min'  => '0',
     151                    'step' => '1',
     152                ),
     153            )
     154        );
     155    echo '<div class="show_if_variable">';
     156    woocommerce_wp_text_input(
     157            array(
     158                'id'                => self::PRODUCT_FIELDS_PREFIX . 'per_style_minimum_order_quantity',
     159                'label'             => __( 'Per style minimum order quantity (Faire)', 'faire-for-woocommerce' ),
     160                'type'                => 'number',
     161        'custom_attributes' => array(
     162                    'min'  => '0',
     163                    'step' => '1',
     164                ),
     165            )
     166        );
     167    echo '</div>';
     168    echo '</div>';
    131169    }
    132170
  • faire-for-woocommerce/tags/1.3.4/src/admin/product/class-simple.php

    r2838583 r2853863  
    108108
    109109        $fields = array(
    110             'wholesale_price'                => 'float',
    111             'retail_price'                   => 'float',
    112             'tariff_code'                    => 'string',
    113             'lifecycle_state'                => 'string',
    114             'allow_preorder'                 => 'string',
    115             'order_by_date'                  => 'string',
    116             'keep_active_past_order_by_date' => 'bool',
    117             'expected_ship_date'             => 'date',
    118             'expected_ship_window_date'      => 'date',
    119             'taxonomy_type'                  => 'string',
     110            'wholesale_price'                  => 'float',
     111            'retail_price'                     => 'float',
     112            'tariff_code'                      => 'string',
     113            'lifecycle_state'                  => 'string',
     114            'allow_preorder'                   => 'string',
     115            'order_by_date'                    => 'string',
     116            'keep_active_past_order_by_date'   => 'bool',
     117            'expected_ship_date'               => 'date',
     118            'expected_ship_window_date'        => 'date',
     119            'taxonomy_type'                    => 'string',
     120      'unit_multiplier'                  => 'string',
     121      'minimum_order_quantity'           => 'string',
     122      'per_style_minimum_order_quantity' => 'string',
    120123        );
    121124
  • faire-for-woocommerce/tags/1.3.4/src/admin/product/class-variation.php

    r2838583 r2853863  
    234234            'expected_ship_window_date'      => 'date',
    235235            'taxonomy_type'                  => 'string',
     236      'unit_multiplier'                  => 'string',
     237      'minimum_order_quantity'           => 'string',
     238      'per_style_minimum_order_quantity' => 'string',
    236239        );
    237240
  • faire-for-woocommerce/tags/1.3.4/src/faire/class-order.php

    r2838583 r2853863  
    4848     */
    4949    public function get_state(): string {
    50         return $this->order_data->state;
     50        return strtoupper( $this->order_data->state );
    5151    }
    5252
  • faire-for-woocommerce/tags/1.3.4/src/sync/class-sync-order-status.php

    r2838583 r2853863  
    4141
    4242    /**
     43     * Option to flag wether it is the first orders sync.
     44     *
     45     * @var string
     46     */
     47    const ORDERS_SYNC_OCCURRENCE = 'faire_orders_sync_occurrence';
     48
     49    /**
    4350     * Date of when last orders sync was started.
    4451     *
     
    96103    public function __construct( FaireAdminSettings $settings ) {
    97104        $this->settings = $settings;
     105    }
     106
     107    /**
     108     * Checks if is the first running orders sync.
     109     *
     110     * @return bool True if is the first running orders sync.
     111     */
     112    public function is_first_orders_sync(): bool {
     113        return $this->get_orders_sync_occurrence() === 'first';
     114    }
     115
     116    /**
     117     * Retrieves the order sync occurrence.
     118     *
     119     * Returned value is 'first' for the first time running orders sync,
     120     * 'not-first' for following orders syncs.
     121     *
     122     * @return string Order sync occurrence.
     123     */
     124    public function get_orders_sync_occurrence(): string {
     125        return get_option( self::ORDERS_SYNC_OCCURRENCE, 'first' );
     126    }
     127
     128    /**
     129     * Updates the order sync occurrence.
     130     */
     131    public function update_orders_sync_occurrence(): bool {
     132        return update_option( self::ORDERS_SYNC_OCCURRENCE, 'not-first' );
    98133    }
    99134
  • faire-for-woocommerce/tags/1.3.4/src/sync/class-sync-order.php

    r2838583 r2853863  
    185185        $this->sync_status->sync_running( true );
    186186        $results = $this->import_orders();
     187        $this->sync_status->update_orders_sync_occurrence();
    187188        $this->sync_status->save_last_sync_finish_timestamp();
    188189        $this->sync_status->save_orders_sync_results( $results );
     
    199200    public function import_orders(): array {
    200201        $synced_orders = array();
     202        $is_first_orders_sync = $this->sync_status->is_first_orders_sync();
    201203
    202204        // We go back 30 days from the last orders sync to ensure no orders
    203         // get stuck un-synced for ever.
     205        // get stuck un-synced forever.
     206        $offset = $is_first_orders_sync ? '-30 days' : '';
    204207        $updated_at_min = gmdate(
    205208            'Y-m-d\TH:i:s.v\Z',
    206             strtotime( $this->sync_status->get_orders_last_sync_date() . ' - 30 days' )
     209            strtotime( $this->sync_status->get_orders_last_sync_date() . $offset )
    207210        );
    208211
     
    234237            // Process the retrieved orders.
    235238            foreach ( $orders as $order ) {
    236                 $faire_order = new Faire_Order( $order );
     239                $faire_order        = new Faire_Order( $order );
     240                $faire_order_status = $faire_order->get_state();
     241
     242                // On first orders sync, we skip Faire orders with following statuses.
     243                $faire_status_skip_first_sync = array( 'PRE_TRANSIT', 'IN_TRANSIT', 'DELIVERED', 'CANCELED' );
     244                if (
     245                    $is_first_orders_sync
     246                    && in_array( $faire_order_status, $faire_status_skip_first_sync, true)
     247                ) {
     248                    $results[] = Utils::create_import_result_entry(
     249                        true,
     250                        sprintf(
     251                            // translators: %1$s Faire order ID, %2$d Faire order status.
     252                            __( 'Faire order skipped on first sync: %1$s. Status %2$s.', 'faire-for-woocommerce' ),
     253                            $faire_order->get_id(),
     254                            $faire_order_status
     255                        )
     256                    );
     257                    continue;
     258                }
     259
     260                $result = array();
    237261                $wc_order_id = WC_Order::get_order_by_faire_id( $faire_order->get_id() );
    238                 $result      = $wc_order_id
    239                     ? $this->sync_order_status( $faire_order, $wc_order_id )
    240                     : $this->sync_faire_to_wc_order( $faire_order, $skip_order_create );
    241 
    242                 if ( 'success' === $result['status'] ) {
     262
     263                // Faire orders with the following statuses should only update a related
     264                // WooCommerce order, never create one.
     265                $faire_status_may_update_order = array( 'PRE_TRANSIT', 'IN_TRANSIT', 'DELIVERED', 'CANCELED' );
     266                if (
     267                    $wc_order_id
     268                    && in_array( $faire_order_status, $faire_status_may_update_order, true)
     269                ) {
     270                    $result = $this->sync_order_status( $faire_order, $wc_order_id );
     271                }
     272
     273                // Faire orders with the following statuses may create or update a related
     274                // WooCommerce order.
     275                $faire_status_sync_order = array( 'NEW', 'PROCESSING', 'BACKORDERED' );
     276                if ( in_array( $faire_order_status, $faire_status_sync_order, true) ) {
     277                    $result = $wc_order_id
     278                        ? $this->sync_order_status( $faire_order, $wc_order_id )
     279                        : $this->sync_faire_to_wc_order( $faire_order, $skip_order_create );
     280                }
     281
     282                if ( $result && 'success' === $result['status'] ) {
    243283                    $synced_orders[] = $faire_order->get_id();
    244284                }
  • faire-for-woocommerce/tags/1.3.4/src/sync/class-sync-product-linking.php

    r2838583 r2853863  
    992992        $row['Meta: '.$this->meta_faire_product_id] = $faire_product->id; // faire product id
    993993        $row['Meta: woocommerce_faire_product_lifecycle_state'] = ( $faire_product->lifecycle_state ) ? $faire_product->lifecycle_state : 'UNPUBLISHED';
     994    $row['Meta: woocommerce_faire_product_unit_multiplier'] = $faire_product->unit_multiplier;
     995        $row['Meta: woocommerce_faire_product_minimum_order_quantity'] = $faire_product->minimum_order_quantity;
     996    $row['Meta: woocommerce_faire_product_per_style_minimum_order_quantity'] = $faire_product->per_style_minimum_order_quantity;
    994997        $row['Meta: woocommerce_faire_product_allow_preorder'] = ( $faire_product->preorderable ) ? 'allow_preorder' : 'do_not_allow';
    995998        if ( isset($faire_product->preorder_details) && $faire_product->preorder_details ) {
  • faire-for-woocommerce/tags/1.3.4/src/sync/class-sync-product.php

    r2849950 r2853863  
    19641964            'lifecycle_state'                  => $this->get_product_lifecycle_state( $product ),
    19651965            'name'                             => $product->get_name(), // REQUIRED.
    1966             'unit_multiplier'                  => apply_filters( 'faire_wc_product_unit_multiplier', 1, $product ), // REQUIRED FOR PUBLISHED.
    1967             'minimum_order_quantity'           => apply_filters( 'faire_wc_product_minimum_order_quantity', 1, $product ),
    1968             'per_style_minimum_order_quantity' => apply_filters( 'faire_wc_product_per_style_minimum_order_quantity', 0, $product ),
     1966            'unit_multiplier'                  => $this->get_faire_product_unit_multiplier( $product ), // REQUIRED FOR PUBLISHED.
     1967            'minimum_order_quantity'           => $this->get_faire_product_minimum_order_quantity( $product ),
     1968            'per_style_minimum_order_quantity' => $this->get_faire_product_per_style_minimum_order_quantity( $product ),
    19691969            'images'                           => $product_images, // REQUIRED FOR PUBLISHED.
    19701970            'preorderable'                     => ( $is_preorderable ) ? true : false,
     
    22322232
    22332233        return apply_filters( 'faire_wc_product_stock_quantity', $qty_if_stock_managed, $product );
     2234    }
     2235 
     2236  /**
     2237     * Get faire product case unit quantity for wc product or variation
     2238     *
     2239     * @return string
     2240     */
     2241    public function get_faire_product_unit_multiplier( $product ) {
     2242        $unit_multiplier = (string) get_post_meta( $product->get_id(), 'woocommerce_faire_product_unit_multiplier', true );
     2243        return apply_filters( 'faire_wc_product_unit_multiplier', $unit_multiplier, $product );
     2244    }
     2245
     2246  /**
     2247     * Get faire product minimum order quantity for wc product or variation
     2248     *
     2249     * @return string
     2250     */
     2251    public function get_faire_product_minimum_order_quantity( $product ) {
     2252        $minimum_order_quantity = (string) get_post_meta( $product->get_id(), 'woocommerce_faire_product_minimum_order_quantity', true );
     2253        return apply_filters( 'faire_wc_product_minimum_order_quantity', $minimum_order_quantity, $product );
     2254    }
     2255
     2256  /**
     2257     * Get faire product per style minimum order quantity for wc product or variation
     2258     *
     2259     * @return string
     2260     */
     2261    public function get_faire_product_per_style_minimum_order_quantity( $product ) {
     2262        $per_style_minimum_order_quantity = (string) get_post_meta( $product->get_id(), 'woocommerce_faire_product_per_style_minimum_order_quantity', true );
     2263        return apply_filters( 'faire_wc_product_per_style_minimum_order_quantity', $per_style_minimum_order_quantity, $product );
    22342264    }
    22352265
  • faire-for-woocommerce/trunk/readme.txt

    r2849961 r2853863  
    44Requires at least: 4.7
    55Tested up to: 6.0
    6 Stable tag: 1.3.2
     6Stable tag: 1.3.4
    77Requires PHP: 7.4
    88WC requires at least: 6.0
Note: See TracChangeset for help on using the changeset viewer.