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 ) {
|
||||
$errors = array();
|
||||
$items = $order->get_items();
|
||||
$location_code = get_option( 'wbc_location_code', '' );
|
||||
|
||||
foreach ( $items as $item_id => $item ) {
|
||||
$product = $item->get_product();
|
||||
@@ -263,6 +264,10 @@ class WBC_Order_Sync {
|
||||
'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
|
||||
$line_description = $item->get_name();
|
||||
if ( ! empty( $line_description ) ) {
|
||||
@@ -300,6 +305,10 @@ class WBC_Order_Sync {
|
||||
'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 );
|
||||
|
||||
if ( is_wp_error( $result ) ) {
|
||||
|
||||
Reference in New Issue
Block a user