Created
September 23, 2017 09:18
-
-
Save BHWD/2f0c4e567be5f14d07837fb1380c702b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
foreach( $order-> get_items() as $item_key => $item_values ): | |
$item_id = $item_values->get_id(); | |
$item_name = $item_values->get_name(); // Name of the product | |
$item_type = $item_values->get_type(); // Type of the order item ("line_item") | |
$product_id = $item_values->get_product_id(); // the Product id | |
$wc_product = $item_values->get_product(); // the WC_Product object | |
$item_data = $item_values->get_data(); | |
$product_name = $item_data['name']; | |
$product_id = $item_data['product_id']; | |
$variation_id = $item_data['variation_id']; | |
$quantity = $item_data['quantity']; | |
$tax_class = $item_data['tax_class']; | |
$line_subtotal = $item_data['subtotal']; | |
$line_subtotal_tax = $item_data['subtotal_tax']; | |
$line_total = $item_data['total']; | |
$line_total_tax = $item_data['total_tax']; | |
$order_id = $item_data['order_id']; | |
if ($product_id == 37) { | |
} else if ($product_id == 50) { | |
$patt_carrier = ''; // This needs to be the value of the custom attibute 'carrier' | |
$patt_template = ''; // This needs to be the value of the custom attibute 'template' | |
$product_type = "PICKANDPACK"; | |
$postData['bundles'][] = [ | |
'type' => $product_type, | |
'items' => [ | |
'bom' => [ | |
[ | |
'type' => 'CARRIER', | |
'quantity' => '1', | |
'stockId' => $patt_carrier, | |
'metadata' => [ | |
'template' => $patt_template, | |
'mergeFields' => [ | |
'to' => '', | |
'msg' => '', | |
'giftAmount' => '', | |
'from' => '' | |
] | |
] | |
], | |
], | |
], | |
'delivery' => [ | |
'method' => 'SHIPPING METHOD HERE', // I need the shipping method name here | |
'shippingAddress' => [ | |
'firstname' => '', | |
'lastname' => '', | |
'addressLine1' => '', | |
'addressLine2' => '', | |
'town' => '', | |
'county' => '', | |
'postcode' => '' | |
] | |
] | |
]; | |
} | |
endforeach; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment