Changeset 3279149
- Timestamp:
- 04/22/2025 02:22:35 PM (11 months ago)
- Location:
- woocommerce-shipstation-integration
- Files:
-
- 10 edited
- 1 copied
-
tags/4.5.1 (copied) (copied from woocommerce-shipstation-integration/trunk)
-
tags/4.5.1/changelog.txt (modified) (1 diff)
-
tags/4.5.1/includes/api-requests/class-wc-shipstation-api-export.php (modified) (5 diffs)
-
tags/4.5.1/languages/woocommerce-shipstation.pot (modified) (2 diffs)
-
tags/4.5.1/readme.txt (modified) (2 diffs)
-
tags/4.5.1/woocommerce-shipstation.php (modified) (2 diffs)
-
trunk/changelog.txt (modified) (1 diff)
-
trunk/includes/api-requests/class-wc-shipstation-api-export.php (modified) (5 diffs)
-
trunk/languages/woocommerce-shipstation.pot (modified) (2 diffs)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/woocommerce-shipstation.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
woocommerce-shipstation-integration/tags/4.5.1/changelog.txt
r3272155 r3279149 1 1 *** ShipStation for WooCommerce *** 2 3 = 4.5.1 - 2025-04-22 = 4 * Add - Include the product dimensions when exporting an order to ShipStation. 5 * Tweak - Added a filter to allow the user to disable exporting order discounts as a separate line item to ShipStation. 2 6 3 7 = 4.5.0 - 2025-04-14 = -
woocommerce-shipstation-integration/tags/4.5.1/includes/api-requests/class-wc-shipstation-api-export.php
r3093733 r3279149 11 11 12 12 use WooCommerce\ShipStation\Order_Util; 13 use Automattic\WooCommerce\Internal\DataStores\Orders\OrdersTableDataStore;14 13 15 14 /** … … 166 165 */ 167 166 $exchange_rate = apply_filters( 'woocommerce_shipstation_export_exchange_rate', 1.00, $order ); 167 /** 168 * Filter whether order discounts should be exported as a separate line item to ShipStation. 169 * 170 * By default (true), discounts are exported as a separate line item. This has been the 171 * behavior since the beginning and is expected by all existing users and integrations. 172 * 173 * If set to false, the discount amount will instead be applied proportionally across the product line items, 174 * and no separate "Discount" line will be included in the export. 175 * 176 * ⚠️ Changing this behavior may break compatibility with external systems or workflows 177 * that rely on the presence of a separate discount line. 178 * 179 * This filter is provided to give developers flexibility in customizing how discounts 180 * are represented in the ShipStation export. 181 * 182 * @see https://linear.app/a8c/issue/WOOSHIP-748/discounts-are-added-in-separate-line-item-as-total-discount-instead-of 183 * @see https://github.com/woocommerce/woocommerce-shipstation/issues/85 184 * 185 * @param bool $export_discounts_as_separate_item Whether to export discounts as a separate ShipStation line item. Default true. 186 * @param WC_Order $order The WooCommerce order object. 187 * 188 * @return bool Modified flag to control export behavior for discounts. 189 * 190 * @since 4.5.1 191 */ 192 $export_discounts_as_separate_item = apply_filters( 'woocommerce_shipstation_export_discounts_as_separate_item', true, $order ); 168 193 169 194 $order_xml = $xml->createElement( 'Order' ); … … 286 311 287 312 // Item data. 288 $found_item = false; 289 $items_xml = $xml->createElement( 'Items' ); 313 $found_item = false; 314 $product_dimensions = array(); 315 $items_xml = $xml->createElement( 'Items' ); 290 316 // Merge arrays without loosing indexes. 291 317 $order_items = $order->get_items() + $order->get_items( 'fee' ); … … 345 371 $this->xml_append( $item_xml, 'Quantity', $item_qty, false ); 346 372 347 $item_ subtotal = $order->get_item_subtotal( $item, false, true );348 349 // Maybe convert item subtotal.373 $item_total = $export_discounts_as_separate_item ? $order->get_item_subtotal( $item, false, true ) : $order->get_item_total( $item, false, true ); 374 375 // Maybe convert item total. 350 376 if ( 1.00 !== $exchange_rate ) { 351 $item_ subtotal = wc_format_decimal( ( $item_subtotal * $exchange_rate ), wc_get_price_decimals() );377 $item_total = wc_format_decimal( ( $item_total * $exchange_rate ), wc_get_price_decimals() ); 352 378 } 353 379 354 $this->xml_append( $item_xml, 'UnitPrice', $item_subtotal, false ); 380 $this->xml_append( $item_xml, 'UnitPrice', $item_total, false ); 381 382 $product_dimensions[] = array( 383 'length' => wc_get_dimension( floatval( $product->get_length() ), 'in' ), 384 'width' => wc_get_dimension( floatval( $product->get_width() ), 'in' ), 385 'height' => wc_get_dimension( floatval( $product->get_height() ), 'in' ), 386 'qty' => $item_qty, 387 ); 355 388 } 356 389 … … 380 413 } 381 414 415 // Get the first product's dimensions. 416 $dimensions = array_shift( $product_dimensions ); 417 418 // Make sure the product item is only 1 and the quantity is also 1. 419 if ( empty( $product_dimensions ) && ! empty( $dimensions['qty'] ) && 1 === $dimensions['qty'] ) { 420 $dimensions_xml = $xml->createElement( 'Dimensions' ); 421 422 $this->xml_append( $dimensions_xml, 'Length', $dimensions['length'], false ); 423 $this->xml_append( $dimensions_xml, 'Width', $dimensions['width'], false ); 424 $this->xml_append( $dimensions_xml, 'Height', $dimensions['height'], false ); 425 $this->xml_append( $dimensions_xml, 'DimensionUnits', 'in', false ); 426 427 $order_xml->appendChild( $dimensions_xml ); 428 } 429 382 430 // Append cart level discount line. 383 if ( $ order->get_total_discount() ) {431 if ( $export_discounts_as_separate_item && $order->get_total_discount() ) { 384 432 $item_xml = $xml->createElement( 'Item' ); 385 433 $this->xml_append( $item_xml, 'SKU', 'total-discount' ); -
woocommerce-shipstation-integration/tags/4.5.1/languages/woocommerce-shipstation.pot
r3272155 r3279149 3 3 msgid "" 4 4 msgstr "" 5 "Project-Id-Version: WooCommerce - ShipStation Integration 4.5. 0\n"5 "Project-Id-Version: WooCommerce - ShipStation Integration 4.5.1\n" 6 6 "Report-Msgid-Bugs-To: " 7 7 "https://wordpress.org/support/plugin/woocommerce-shipstation\n" 8 "POT-Creation-Date: 2025-04- 14 09:02:31+00:00\n"8 "POT-Creation-Date: 2025-04-22 14:22:13+00:00\n" 9 9 "MIME-Version: 1.0\n" 10 10 "Content-Type: text/plain; charset=utf-8\n" … … 15 15 "X-Generator: node-wp-i18n 1.2.7\n" 16 16 17 #: includes/api-requests/class-wc-shipstation-api-export.php:14 117 #: includes/api-requests/class-wc-shipstation-api-export.php:140 18 18 #. translators: 1: order id 19 19 msgid "Order %s can not be found." 20 20 msgstr "" 21 21 22 #: includes/api-requests/class-wc-shipstation-api-export.php: 38622 #: includes/api-requests/class-wc-shipstation-api-export.php:434 23 23 msgid "Total Discount" 24 24 msgstr "" 25 25 26 #: includes/api-requests/class-wc-shipstation-api-export.php:4 1526 #: includes/api-requests/class-wc-shipstation-api-export.php:463 27 27 msgid "Order has been exported to Shipstation" 28 28 msgstr "" 29 29 30 #: includes/api-requests/class-wc-shipstation-api-export.php:4 2730 #: includes/api-requests/class-wc-shipstation-api-export.php:475 31 31 #. translators: 1: total count 32 32 msgid "Exported %s orders" -
woocommerce-shipstation-integration/tags/4.5.1/readme.txt
r3272155 r3279149 4 4 Requires at least: 6.6 5 5 Tested up to: 6.7 6 WC tested up to: 9. 77 WC requires at least: 9. 56 WC tested up to: 9.8 7 WC requires at least: 9.6 8 8 Requires PHP: 7.4 9 9 Requires Plugins: woocommerce 10 Stable tag: 4.5. 010 Stable tag: 4.5.1 11 11 License: GPLv3 12 12 License URI: https://www.gnu.org/licenses/gpl-3.0.html … … 68 68 69 69 == Changelog == 70 71 = 4.5.1 - 2025-04-22 = 72 * Add - Include the product dimensions when exporting an order to ShipStation. 73 * Tweak - Added a filter to allow the user to disable exporting order discounts as a separate line item to ShipStation. 70 74 71 75 = 4.5.0 - 2025-04-14 = -
woocommerce-shipstation-integration/tags/4.5.1/woocommerce-shipstation.php
r3272155 r3279149 3 3 * Plugin Name: WooCommerce - ShipStation Integration 4 4 * Plugin URI: https://woocommerce.com/products/shipstation-integration/ 5 * Version: 4.5. 05 * Version: 4.5.1 6 6 * Description: Adds ShipStation label printing support to WooCommerce. Requires server DomDocument support. 7 7 * Author: WooCommerce … … 50 50 } 51 51 52 define( 'WC_SHIPSTATION_VERSION', '4.5. 0' ); // WRCS: DEFINED_VERSION.52 define( 'WC_SHIPSTATION_VERSION', '4.5.1' ); // WRCS: DEFINED_VERSION. 53 53 54 54 if ( ! defined( 'WC_SHIPSTATION_EXPORT_LIMIT' ) ) { -
woocommerce-shipstation-integration/trunk/changelog.txt
r3272155 r3279149 1 1 *** ShipStation for WooCommerce *** 2 3 = 4.5.1 - 2025-04-22 = 4 * Add - Include the product dimensions when exporting an order to ShipStation. 5 * Tweak - Added a filter to allow the user to disable exporting order discounts as a separate line item to ShipStation. 2 6 3 7 = 4.5.0 - 2025-04-14 = -
woocommerce-shipstation-integration/trunk/includes/api-requests/class-wc-shipstation-api-export.php
r3093733 r3279149 11 11 12 12 use WooCommerce\ShipStation\Order_Util; 13 use Automattic\WooCommerce\Internal\DataStores\Orders\OrdersTableDataStore;14 13 15 14 /** … … 166 165 */ 167 166 $exchange_rate = apply_filters( 'woocommerce_shipstation_export_exchange_rate', 1.00, $order ); 167 /** 168 * Filter whether order discounts should be exported as a separate line item to ShipStation. 169 * 170 * By default (true), discounts are exported as a separate line item. This has been the 171 * behavior since the beginning and is expected by all existing users and integrations. 172 * 173 * If set to false, the discount amount will instead be applied proportionally across the product line items, 174 * and no separate "Discount" line will be included in the export. 175 * 176 * ⚠️ Changing this behavior may break compatibility with external systems or workflows 177 * that rely on the presence of a separate discount line. 178 * 179 * This filter is provided to give developers flexibility in customizing how discounts 180 * are represented in the ShipStation export. 181 * 182 * @see https://linear.app/a8c/issue/WOOSHIP-748/discounts-are-added-in-separate-line-item-as-total-discount-instead-of 183 * @see https://github.com/woocommerce/woocommerce-shipstation/issues/85 184 * 185 * @param bool $export_discounts_as_separate_item Whether to export discounts as a separate ShipStation line item. Default true. 186 * @param WC_Order $order The WooCommerce order object. 187 * 188 * @return bool Modified flag to control export behavior for discounts. 189 * 190 * @since 4.5.1 191 */ 192 $export_discounts_as_separate_item = apply_filters( 'woocommerce_shipstation_export_discounts_as_separate_item', true, $order ); 168 193 169 194 $order_xml = $xml->createElement( 'Order' ); … … 286 311 287 312 // Item data. 288 $found_item = false; 289 $items_xml = $xml->createElement( 'Items' ); 313 $found_item = false; 314 $product_dimensions = array(); 315 $items_xml = $xml->createElement( 'Items' ); 290 316 // Merge arrays without loosing indexes. 291 317 $order_items = $order->get_items() + $order->get_items( 'fee' ); … … 345 371 $this->xml_append( $item_xml, 'Quantity', $item_qty, false ); 346 372 347 $item_ subtotal = $order->get_item_subtotal( $item, false, true );348 349 // Maybe convert item subtotal.373 $item_total = $export_discounts_as_separate_item ? $order->get_item_subtotal( $item, false, true ) : $order->get_item_total( $item, false, true ); 374 375 // Maybe convert item total. 350 376 if ( 1.00 !== $exchange_rate ) { 351 $item_ subtotal = wc_format_decimal( ( $item_subtotal * $exchange_rate ), wc_get_price_decimals() );377 $item_total = wc_format_decimal( ( $item_total * $exchange_rate ), wc_get_price_decimals() ); 352 378 } 353 379 354 $this->xml_append( $item_xml, 'UnitPrice', $item_subtotal, false ); 380 $this->xml_append( $item_xml, 'UnitPrice', $item_total, false ); 381 382 $product_dimensions[] = array( 383 'length' => wc_get_dimension( floatval( $product->get_length() ), 'in' ), 384 'width' => wc_get_dimension( floatval( $product->get_width() ), 'in' ), 385 'height' => wc_get_dimension( floatval( $product->get_height() ), 'in' ), 386 'qty' => $item_qty, 387 ); 355 388 } 356 389 … … 380 413 } 381 414 415 // Get the first product's dimensions. 416 $dimensions = array_shift( $product_dimensions ); 417 418 // Make sure the product item is only 1 and the quantity is also 1. 419 if ( empty( $product_dimensions ) && ! empty( $dimensions['qty'] ) && 1 === $dimensions['qty'] ) { 420 $dimensions_xml = $xml->createElement( 'Dimensions' ); 421 422 $this->xml_append( $dimensions_xml, 'Length', $dimensions['length'], false ); 423 $this->xml_append( $dimensions_xml, 'Width', $dimensions['width'], false ); 424 $this->xml_append( $dimensions_xml, 'Height', $dimensions['height'], false ); 425 $this->xml_append( $dimensions_xml, 'DimensionUnits', 'in', false ); 426 427 $order_xml->appendChild( $dimensions_xml ); 428 } 429 382 430 // Append cart level discount line. 383 if ( $ order->get_total_discount() ) {431 if ( $export_discounts_as_separate_item && $order->get_total_discount() ) { 384 432 $item_xml = $xml->createElement( 'Item' ); 385 433 $this->xml_append( $item_xml, 'SKU', 'total-discount' ); -
woocommerce-shipstation-integration/trunk/languages/woocommerce-shipstation.pot
r3272155 r3279149 3 3 msgid "" 4 4 msgstr "" 5 "Project-Id-Version: WooCommerce - ShipStation Integration 4.5. 0\n"5 "Project-Id-Version: WooCommerce - ShipStation Integration 4.5.1\n" 6 6 "Report-Msgid-Bugs-To: " 7 7 "https://wordpress.org/support/plugin/woocommerce-shipstation\n" 8 "POT-Creation-Date: 2025-04- 14 09:02:31+00:00\n"8 "POT-Creation-Date: 2025-04-22 14:22:13+00:00\n" 9 9 "MIME-Version: 1.0\n" 10 10 "Content-Type: text/plain; charset=utf-8\n" … … 15 15 "X-Generator: node-wp-i18n 1.2.7\n" 16 16 17 #: includes/api-requests/class-wc-shipstation-api-export.php:14 117 #: includes/api-requests/class-wc-shipstation-api-export.php:140 18 18 #. translators: 1: order id 19 19 msgid "Order %s can not be found." 20 20 msgstr "" 21 21 22 #: includes/api-requests/class-wc-shipstation-api-export.php: 38622 #: includes/api-requests/class-wc-shipstation-api-export.php:434 23 23 msgid "Total Discount" 24 24 msgstr "" 25 25 26 #: includes/api-requests/class-wc-shipstation-api-export.php:4 1526 #: includes/api-requests/class-wc-shipstation-api-export.php:463 27 27 msgid "Order has been exported to Shipstation" 28 28 msgstr "" 29 29 30 #: includes/api-requests/class-wc-shipstation-api-export.php:4 2730 #: includes/api-requests/class-wc-shipstation-api-export.php:475 31 31 #. translators: 1: total count 32 32 msgid "Exported %s orders" -
woocommerce-shipstation-integration/trunk/readme.txt
r3272155 r3279149 4 4 Requires at least: 6.6 5 5 Tested up to: 6.7 6 WC tested up to: 9. 77 WC requires at least: 9. 56 WC tested up to: 9.8 7 WC requires at least: 9.6 8 8 Requires PHP: 7.4 9 9 Requires Plugins: woocommerce 10 Stable tag: 4.5. 010 Stable tag: 4.5.1 11 11 License: GPLv3 12 12 License URI: https://www.gnu.org/licenses/gpl-3.0.html … … 68 68 69 69 == Changelog == 70 71 = 4.5.1 - 2025-04-22 = 72 * Add - Include the product dimensions when exporting an order to ShipStation. 73 * Tweak - Added a filter to allow the user to disable exporting order discounts as a separate line item to ShipStation. 70 74 71 75 = 4.5.0 - 2025-04-14 = -
woocommerce-shipstation-integration/trunk/woocommerce-shipstation.php
r3272155 r3279149 3 3 * Plugin Name: WooCommerce - ShipStation Integration 4 4 * Plugin URI: https://woocommerce.com/products/shipstation-integration/ 5 * Version: 4.5. 05 * Version: 4.5.1 6 6 * Description: Adds ShipStation label printing support to WooCommerce. Requires server DomDocument support. 7 7 * Author: WooCommerce … … 50 50 } 51 51 52 define( 'WC_SHIPSTATION_VERSION', '4.5. 0' ); // WRCS: DEFINED_VERSION.52 define( 'WC_SHIPSTATION_VERSION', '4.5.1' ); // WRCS: DEFINED_VERSION. 53 53 54 54 if ( ! defined( 'WC_SHIPSTATION_EXPORT_LIMIT' ) ) {
Note: See TracChangeset
for help on using the changeset viewer.