Skip to content

Instantly share code, notes, and snippets.

@blogwerk
Created November 22, 2013 14:17
Show Gist options
  • Save blogwerk/7600547 to your computer and use it in GitHub Desktop.
Save blogwerk/7600547 to your computer and use it in GitHub Desktop.
<?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