Plugin Directory

Changeset 3279149


Ignore:
Timestamp:
04/22/2025 02:22:35 PM (11 months ago)
Author:
SamNajian
Message:

Tagging version 4.5.1

Location:
woocommerce-shipstation-integration
Files:
10 edited
1 copied

Legend:

Unmodified
Added
Removed
  • woocommerce-shipstation-integration/tags/4.5.1/changelog.txt

    r3272155 r3279149  
    11*** 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.
    26
    37= 4.5.0 - 2025-04-14 =
  • woocommerce-shipstation-integration/tags/4.5.1/includes/api-requests/class-wc-shipstation-api-export.php

    r3093733 r3279149  
    1111
    1212use WooCommerce\ShipStation\Order_Util;
    13 use Automattic\WooCommerce\Internal\DataStores\Orders\OrdersTableDataStore;
    1413
    1514/**
     
    166165             */
    167166            $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 );
    168193
    169194            $order_xml              = $xml->createElement( 'Order' );
     
    286311
    287312            // 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' );
    290316            // Merge arrays without loosing indexes.
    291317            $order_items = $order->get_items() + $order->get_items( 'fee' );
     
    345371                    $this->xml_append( $item_xml, 'Quantity', $item_qty, false );
    346372
    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.
    350376                    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() );
    352378                    }
    353379
    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                    );
    355388                }
    356389
     
    380413            }
    381414
     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
    382430            // Append cart level discount line.
    383             if ( $order->get_total_discount() ) {
     431            if ( $export_discounts_as_separate_item && $order->get_total_discount() ) {
    384432                $item_xml = $xml->createElement( 'Item' );
    385433                $this->xml_append( $item_xml, 'SKU', 'total-discount' );
  • woocommerce-shipstation-integration/tags/4.5.1/languages/woocommerce-shipstation.pot

    r3272155 r3279149  
    33msgid ""
    44msgstr ""
    5 "Project-Id-Version: WooCommerce - ShipStation Integration 4.5.0\n"
     5"Project-Id-Version: WooCommerce - ShipStation Integration 4.5.1\n"
    66"Report-Msgid-Bugs-To: "
    77"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"
    99"MIME-Version: 1.0\n"
    1010"Content-Type: text/plain; charset=utf-8\n"
     
    1515"X-Generator: node-wp-i18n 1.2.7\n"
    1616
    17 #: includes/api-requests/class-wc-shipstation-api-export.php:141
     17#: includes/api-requests/class-wc-shipstation-api-export.php:140
    1818#. translators: 1: order id
    1919msgid "Order %s can not be found."
    2020msgstr ""
    2121
    22 #: includes/api-requests/class-wc-shipstation-api-export.php:386
     22#: includes/api-requests/class-wc-shipstation-api-export.php:434
    2323msgid "Total Discount"
    2424msgstr ""
    2525
    26 #: includes/api-requests/class-wc-shipstation-api-export.php:415
     26#: includes/api-requests/class-wc-shipstation-api-export.php:463
    2727msgid "Order has been exported to Shipstation"
    2828msgstr ""
    2929
    30 #: includes/api-requests/class-wc-shipstation-api-export.php:427
     30#: includes/api-requests/class-wc-shipstation-api-export.php:475
    3131#. translators: 1: total count
    3232msgid "Exported %s orders"
  • woocommerce-shipstation-integration/tags/4.5.1/readme.txt

    r3272155 r3279149  
    44Requires at least: 6.6
    55Tested up to: 6.7
    6 WC tested up to: 9.7
    7 WC requires at least: 9.5
     6WC tested up to: 9.8
     7WC requires at least: 9.6
    88Requires PHP: 7.4
    99Requires Plugins: woocommerce
    10 Stable tag: 4.5.0
     10Stable tag: 4.5.1
    1111License: GPLv3
    1212License URI: https://www.gnu.org/licenses/gpl-3.0.html
     
    6868
    6969== 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.
    7074
    7175= 4.5.0 - 2025-04-14 =
  • woocommerce-shipstation-integration/tags/4.5.1/woocommerce-shipstation.php

    r3272155 r3279149  
    33 * Plugin Name: WooCommerce - ShipStation Integration
    44 * Plugin URI: https://woocommerce.com/products/shipstation-integration/
    5  * Version: 4.5.0
     5 * Version: 4.5.1
    66 * Description: Adds ShipStation label printing support to WooCommerce. Requires server DomDocument support.
    77 * Author: WooCommerce
     
    5050    }
    5151
    52     define( 'WC_SHIPSTATION_VERSION', '4.5.0' ); // WRCS: DEFINED_VERSION.
     52    define( 'WC_SHIPSTATION_VERSION', '4.5.1' ); // WRCS: DEFINED_VERSION.
    5353
    5454    if ( ! defined( 'WC_SHIPSTATION_EXPORT_LIMIT' ) ) {
  • woocommerce-shipstation-integration/trunk/changelog.txt

    r3272155 r3279149  
    11*** 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.
    26
    37= 4.5.0 - 2025-04-14 =
  • woocommerce-shipstation-integration/trunk/includes/api-requests/class-wc-shipstation-api-export.php

    r3093733 r3279149  
    1111
    1212use WooCommerce\ShipStation\Order_Util;
    13 use Automattic\WooCommerce\Internal\DataStores\Orders\OrdersTableDataStore;
    1413
    1514/**
     
    166165             */
    167166            $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 );
    168193
    169194            $order_xml              = $xml->createElement( 'Order' );
     
    286311
    287312            // 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' );
    290316            // Merge arrays without loosing indexes.
    291317            $order_items = $order->get_items() + $order->get_items( 'fee' );
     
    345371                    $this->xml_append( $item_xml, 'Quantity', $item_qty, false );
    346372
    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.
    350376                    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() );
    352378                    }
    353379
    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                    );
    355388                }
    356389
     
    380413            }
    381414
     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
    382430            // Append cart level discount line.
    383             if ( $order->get_total_discount() ) {
     431            if ( $export_discounts_as_separate_item && $order->get_total_discount() ) {
    384432                $item_xml = $xml->createElement( 'Item' );
    385433                $this->xml_append( $item_xml, 'SKU', 'total-discount' );
  • woocommerce-shipstation-integration/trunk/languages/woocommerce-shipstation.pot

    r3272155 r3279149  
    33msgid ""
    44msgstr ""
    5 "Project-Id-Version: WooCommerce - ShipStation Integration 4.5.0\n"
     5"Project-Id-Version: WooCommerce - ShipStation Integration 4.5.1\n"
    66"Report-Msgid-Bugs-To: "
    77"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"
    99"MIME-Version: 1.0\n"
    1010"Content-Type: text/plain; charset=utf-8\n"
     
    1515"X-Generator: node-wp-i18n 1.2.7\n"
    1616
    17 #: includes/api-requests/class-wc-shipstation-api-export.php:141
     17#: includes/api-requests/class-wc-shipstation-api-export.php:140
    1818#. translators: 1: order id
    1919msgid "Order %s can not be found."
    2020msgstr ""
    2121
    22 #: includes/api-requests/class-wc-shipstation-api-export.php:386
     22#: includes/api-requests/class-wc-shipstation-api-export.php:434
    2323msgid "Total Discount"
    2424msgstr ""
    2525
    26 #: includes/api-requests/class-wc-shipstation-api-export.php:415
     26#: includes/api-requests/class-wc-shipstation-api-export.php:463
    2727msgid "Order has been exported to Shipstation"
    2828msgstr ""
    2929
    30 #: includes/api-requests/class-wc-shipstation-api-export.php:427
     30#: includes/api-requests/class-wc-shipstation-api-export.php:475
    3131#. translators: 1: total count
    3232msgid "Exported %s orders"
  • woocommerce-shipstation-integration/trunk/readme.txt

    r3272155 r3279149  
    44Requires at least: 6.6
    55Tested up to: 6.7
    6 WC tested up to: 9.7
    7 WC requires at least: 9.5
     6WC tested up to: 9.8
     7WC requires at least: 9.6
    88Requires PHP: 7.4
    99Requires Plugins: woocommerce
    10 Stable tag: 4.5.0
     10Stable tag: 4.5.1
    1111License: GPLv3
    1212License URI: https://www.gnu.org/licenses/gpl-3.0.html
     
    6868
    6969== 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.
    7074
    7175= 4.5.0 - 2025-04-14 =
  • woocommerce-shipstation-integration/trunk/woocommerce-shipstation.php

    r3272155 r3279149  
    33 * Plugin Name: WooCommerce - ShipStation Integration
    44 * Plugin URI: https://woocommerce.com/products/shipstation-integration/
    5  * Version: 4.5.0
     5 * Version: 4.5.1
    66 * Description: Adds ShipStation label printing support to WooCommerce. Requires server DomDocument support.
    77 * Author: WooCommerce
     
    5050    }
    5151
    52     define( 'WC_SHIPSTATION_VERSION', '4.5.0' ); // WRCS: DEFINED_VERSION.
     52    define( 'WC_SHIPSTATION_VERSION', '4.5.1' ); // WRCS: DEFINED_VERSION.
    5353
    5454    if ( ! defined( 'WC_SHIPSTATION_EXPORT_LIMIT' ) ) {
Note: See TracChangeset for help on using the changeset viewer.