feat: add locationCode to sales order lines
Uses wbc_location_code setting on all order lines including shipping. Header-level location to be handled by BC extension post-processing. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -231,6 +231,7 @@ class WBC_Order_Sync {
|
|||||||
private function create_sales_order_lines( $order, $bc_order_id ) {
|
private function create_sales_order_lines( $order, $bc_order_id ) {
|
||||||
$errors = array();
|
$errors = array();
|
||||||
$items = $order->get_items();
|
$items = $order->get_items();
|
||||||
|
$location_code = get_option( 'wbc_location_code', '' );
|
||||||
|
|
||||||
foreach ( $items as $item_id => $item ) {
|
foreach ( $items as $item_id => $item ) {
|
||||||
$product = $item->get_product();
|
$product = $item->get_product();
|
||||||
@@ -263,6 +264,10 @@ class WBC_Order_Sync {
|
|||||||
'unitPrice' => (float) $order->get_item_total( $item, false, false ),
|
'unitPrice' => (float) $order->get_item_total( $item, false, false ),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if ( ! empty( $location_code ) ) {
|
||||||
|
$line_data['locationCode'] = $location_code;
|
||||||
|
}
|
||||||
|
|
||||||
// Add description if different from product name
|
// Add description if different from product name
|
||||||
$line_description = $item->get_name();
|
$line_description = $item->get_name();
|
||||||
if ( ! empty( $line_description ) ) {
|
if ( ! empty( $line_description ) ) {
|
||||||
@@ -300,6 +305,10 @@ class WBC_Order_Sync {
|
|||||||
'description' => __( 'Shipping', 'woo-business-central' ),
|
'description' => __( 'Shipping', 'woo-business-central' ),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if ( ! empty( $location_code ) ) {
|
||||||
|
$shipping_line['locationCode'] = $location_code;
|
||||||
|
}
|
||||||
|
|
||||||
$result = WBC_API_Client::create_sales_order_line( $bc_order_id, $shipping_line );
|
$result = WBC_API_Client::create_sales_order_line( $bc_order_id, $shipping_line );
|
||||||
|
|
||||||
if ( is_wp_error( $result ) ) {
|
if ( is_wp_error( $result ) ) {
|
||||||
|
|||||||
Reference in New Issue
Block a user