Created
November 22, 2013 14:17
-
-
Save blogwerk/7600547 to your computer and use it in GitHub Desktop.
This file contains 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 | |
// Create the manual order | |
$order = new WooCommerce_ManualOrder(); | |
// Initialize the order with the currently logged in user | |
$order->initializeOrder($userId); | |
// Set error pages | |
$order->setErrorPages( | |
get_permalink() . '?view=showError&type=no-stock', // if a product is not available in stock | |
get_permalink() . '?view=showError&type=order-error' // if there's a creating error on the order | |
); | |
// Set "cod" as payment -> means cash on delivery | |
$order->setPaymentId('cod'); | |
// Add the product in the needed quantity | |
$order->addProduct($prodId, $prodCount); | |
// Set the address | |
$order->setBillingAddress('firstname', 'lastname', 'street', 8002, 'Zurich', 'email', 'company'); | |
// If everything went well, finish the order | |
$orderId = $order->finishOrder(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment