I’m using Woocommerce to manage my products on Wordpress, but the user pay through a 3rd party service.
I’m trying to create new order manually, and assign it to the current user.The order is indeed created and logged but the following code only log the item and the time, no details of the user:
global $woocommerce;
$address = array(
'first_name' => $_GET['FirstName'],
'last_name' => $_GET['LastName'],
'company' => $_GET['CompanyName'],
'email' => $_GET['EmailAddress'],
'phone' => $_GET['MobilePhoneNumber'],
'address_1' => '',
'address_2' => '',
'city' => '',
'state' => '',
'postcode' => '',
'country' => $_GET['countryCode']
);
$order = wc_create_order();
foreach ($woocommerce->cart->get_cart() as $cart_item_key => $values) {
$item_id = $order->add_product(
$values['data'], $values['quantity'], array(
'variation' => $values['variation'],
'totals' => array(
'subtotal' => $values['line_subtotal'],
'subtotal_tax' => $values['line_subtotal_tax'],
'total' => $values['line_total'],
'tax' => $values['line_tax'],
'tax_data' => $values['line_tax_data'] // Since 2.2
)
)
);
}
$order->set_address( $address, 'billing' );
//
$order->calculate_totals();
$order->update_status("Completed", 'Imported order', TRUE);
$order->save();
The admin can see what was ordered (under woocommerce->orders) but not by whom, and the user can’t see his orders at all.
I've uploaded the website to a temporary domain so you guys can see: https://360transformations.000webhostapp.com/?page_id=446