Reputation: 378
How can i set shipping method of an order while creating a new order programatically using BigCommerce api PHP library: Here is the code i'm using for creating an order:
$createFields = array(
"customer_id"=>0,
"status_id"=> 1,
"date_created"=> $o_date,
"subtotal_ex_tax"=> strip_tags($xmlObj1->itemsTotal->asXML()),
"subtotal_inc_tax"=> floatval(strip_tags($xmlObj1->itemsTotal->asXML())) + floatval(strip_tags($xmlObj1->dutyTaxesTotal->asXML())),
"base_shipping_cost"=> strip_tags($xmlObj1->shippingTotal->asXML()),
"shipping_cost_ex_tax"=> strip_tags($xmlObj1->shippingTotal->asXML()),
"shipping_cost_inc_tax"=> strip_tags($xmlObj1->shippingTotal->asXML()),
//"base_handling_cost"=> 0,
//"handling_cost_ex_tax"=> 0,
//"handling_cost_inc_tax"=> 0,
//"base_wrapping_cost"=> 0,
//"wrapping_cost_ex_tax"=> 0,
//"wrapping_cost_inc_tax"=> 0,
"total_ex_tax"=> floatval(strip_tags($xmlObj1->grandTotal->asXML())) - floatval(strip_tags($xmlObj1->dutyTaxesTotal->asXML())),
"total_inc_tax"=> strip_tags($xmlObj1->grandTotal->asXML()),
//"refunded_amount"=> 0,
//"order_is_digital"=> false,
"staff_notes"=> strip_tags($xmlObj1->shippingCarrierServiceLevel->asXML()),
//"customer_message"=> "",
//"discount_amount"=> 10,
"billing_address"=> array(
"first_name"=> $billing_name[0],
"last_name"=> $billing_name[1],
"company"=> strip_tags($xmlObj1->company->asXML()),
"street_1"=> strip_tags($xmlObj1->billingAddress1->asXML()),
"street_2"=> strip_tags($xmlObj1->billingAddress2->asXML()),
"city"=> strip_tags($xmlObj1->billingCity->asXML()),
"state"=> strip_tags($xmlObj1->billingState->asXML()),
"zip"=> strip_tags($xmlObj1->billingZip->asXML()),
"country"=> strip_tags($xmlObj1->billingCountryName->asXML()),
"country_iso2"=> strip_tags($xmlObj1->billingCountryCode->asXML()),
"phone"=> strip_tags($xmlObj1->billingPhone->asXML()),
"email"=> strip_tags($xmlObj1->email->asXML())
),
"shipping_addresses"=> array(
array(
"first_name"=> $name[0],
"last_name"=> $name[1],
"company"=> strip_tags($xmlObj1->company->asXML()),
"street_1"=> strip_tags($xmlObj1->address1->asXML()),
"street_2"=> strip_tags($xmlObj1->address2->asXML()),
"city"=> strip_tags($xmlObj1->city->asXML()),
"state"=> strip_tags($xmlObj1->state->asXML()),
"zip"=> strip_tags($xmlObj1->zip->asXML()),
"country"=> strip_tags($xmlObj1->countryName->asXML()),
"country_iso2"=> strip_tags($xmlObj1->countryCode->asXML()),
"phone"=> strip_tags($xmlObj1->phone->asXML()),
"email"=> strip_tags($xmlObj1->email->asXML())
)
),
"products"=> $products,
"external_source"=> "iGlobal",
);
$bc_order_created = Bigcommerce::createOrder($createFields);
Is there a field that will set shipping method or should i use another api call?
Upvotes: 1
Views: 211
Reputation: 923
Shipping method is not a property that is part of the Orders resource. You want to assign it as part of shipments.
Upvotes: 1