Changeset 2853863
- Timestamp:
- 01/24/2023 06:33:55 PM (3 years ago)
- Location:
- faire-for-woocommerce
- Files:
-
- 11 edited
- 2 copied
-
tags/1.3.4 (copied) (copied from faire-for-woocommerce/tags/1.3.2)
-
tags/1.3.4/faire-for-woocommerce.php (modified) (2 diffs)
-
tags/1.3.4/readme.txt (copied) (copied from faire-for-woocommerce/tags/1.3.2/readme.txt) (2 diffs)
-
tags/1.3.4/src/admin/class-wc-integration-faire.php (modified) (1 diff)
-
tags/1.3.4/src/admin/product/class-product.php (modified) (1 diff)
-
tags/1.3.4/src/admin/product/class-simple.php (modified) (1 diff)
-
tags/1.3.4/src/admin/product/class-variation.php (modified) (1 diff)
-
tags/1.3.4/src/faire/class-order.php (modified) (1 diff)
-
tags/1.3.4/src/sync/class-sync-order-status.php (modified) (2 diffs)
-
tags/1.3.4/src/sync/class-sync-order.php (modified) (3 diffs)
-
tags/1.3.4/src/sync/class-sync-product-linking.php (modified) (1 diff)
-
tags/1.3.4/src/sync/class-sync-product.php (modified) (2 diffs)
-
trunk/readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
faire-for-woocommerce/tags/1.3.4/faire-for-woocommerce.php
r2849950 r2853863 5 5 * Author: Faire 6 6 * Author URI: https://faire.com/ 7 * Version: 1.3. 27 * Version: 1.3.4 8 8 * 9 9 * This program is free software: you can redistribute it and/or modify … … 29 29 } 30 30 31 const VERSION = '1.3. 2';31 const VERSION = '1.3.4'; 32 32 33 33 if ( ! defined( 'FAIRE_WC_PLUGIN_FILE' ) ) { -
faire-for-woocommerce/tags/1.3.4/readme.txt
r2849951 r2853863 4 4 Requires at least: 4.7 5 5 Tested up to: 6.0 6 Stable tag: 1.3. 26 Stable tag: 1.3.3 7 7 Requires PHP: 7.4 8 8 WC requires at least: 6.0 … … 64 64 65 65 This 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. 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. 67 67 68 68 = Can I only sync inventory? = 69 69 70 Yes - you can choose to only sync inventory from WooCommerce to Faire. 70 Yes - you can choose to only sync inventory from WooCommerce to Faire. 71 71 I don’t want to sync all product details from WooCommerce to Faire (I use different images/prices/etc) 72 72 You 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. 73 73 74 74 == 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 75 82 76 83 = 1.3.2 = -
faire-for-woocommerce/tags/1.3.4/src/admin/class-wc-integration-faire.php
r2838583 r2853863 430 430 'product.allow_sales_when_out_of_stock' => __( 'Allow Sales When Out Of Stock', 'faire-for-woocommerce' ), 431 431 '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' ), 432 435 'variant.sku' => __( 'Variant SKU', 'faire-for-woocommerce' ), 433 436 'variant.tariff_code' => __( 'Variant Tariff Code', 'faire-for-woocommerce' ), -
faire-for-woocommerce/tags/1.3.4/src/admin/product/class-product.php
r2838583 r2853863 129 129 echo '</div>'; 130 130 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>'; 131 169 } 132 170 -
faire-for-woocommerce/tags/1.3.4/src/admin/product/class-simple.php
r2838583 r2853863 108 108 109 109 $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', 120 123 ); 121 124 -
faire-for-woocommerce/tags/1.3.4/src/admin/product/class-variation.php
r2838583 r2853863 234 234 'expected_ship_window_date' => 'date', 235 235 'taxonomy_type' => 'string', 236 'unit_multiplier' => 'string', 237 'minimum_order_quantity' => 'string', 238 'per_style_minimum_order_quantity' => 'string', 236 239 ); 237 240 -
faire-for-woocommerce/tags/1.3.4/src/faire/class-order.php
r2838583 r2853863 48 48 */ 49 49 public function get_state(): string { 50 return $this->order_data->state;50 return strtoupper( $this->order_data->state ); 51 51 } 52 52 -
faire-for-woocommerce/tags/1.3.4/src/sync/class-sync-order-status.php
r2838583 r2853863 41 41 42 42 /** 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 /** 43 50 * Date of when last orders sync was started. 44 51 * … … 96 103 public function __construct( FaireAdminSettings $settings ) { 97 104 $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' ); 98 133 } 99 134 -
faire-for-woocommerce/tags/1.3.4/src/sync/class-sync-order.php
r2838583 r2853863 185 185 $this->sync_status->sync_running( true ); 186 186 $results = $this->import_orders(); 187 $this->sync_status->update_orders_sync_occurrence(); 187 188 $this->sync_status->save_last_sync_finish_timestamp(); 188 189 $this->sync_status->save_orders_sync_results( $results ); … … 199 200 public function import_orders(): array { 200 201 $synced_orders = array(); 202 $is_first_orders_sync = $this->sync_status->is_first_orders_sync(); 201 203 202 204 // 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' : ''; 204 207 $updated_at_min = gmdate( 205 208 '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 ) 207 210 ); 208 211 … … 234 237 // Process the retrieved orders. 235 238 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(); 237 261 $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'] ) { 243 283 $synced_orders[] = $faire_order->get_id(); 244 284 } -
faire-for-woocommerce/tags/1.3.4/src/sync/class-sync-product-linking.php
r2838583 r2853863 992 992 $row['Meta: '.$this->meta_faire_product_id] = $faire_product->id; // faire product id 993 993 $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; 994 997 $row['Meta: woocommerce_faire_product_allow_preorder'] = ( $faire_product->preorderable ) ? 'allow_preorder' : 'do_not_allow'; 995 998 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 1964 1964 'lifecycle_state' => $this->get_product_lifecycle_state( $product ), 1965 1965 '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 ), 1969 1969 'images' => $product_images, // REQUIRED FOR PUBLISHED. 1970 1970 'preorderable' => ( $is_preorderable ) ? true : false, … … 2232 2232 2233 2233 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 ); 2234 2264 } 2235 2265 -
faire-for-woocommerce/trunk/readme.txt
r2849961 r2853863 4 4 Requires at least: 4.7 5 5 Tested up to: 6.0 6 Stable tag: 1.3. 26 Stable tag: 1.3.4 7 7 Requires PHP: 7.4 8 8 WC requires at least: 6.0
Note: See TracChangeset
for help on using the changeset viewer.