Okay, so since I received no response and before Stackoverflow terms this as an invalid Question.
I've developed my own plugin which basically checks when an external product button is clicked and then perform the order entry based on the Product_ID and Current User ID with the order status as Pending.
My JQuery Script is as follows
jQuery(document).ready(function($) {
$(document).off( 'click', '#affiliate' );
$(document).on( 'click', '#affiliate', function() {
//Code Here
var prodid = $("#prodid").text();
alert( prodid );
var odata = {
'action': 'pending_order',
security: wp_ajax_eaco.ajaxnonce,
prod_id: prodid
};
$.post(
wp_ajax_eaco.ajaxurl,
odata, function(response) {
alert('Got this from the server: ' + response);
});
});
});
And my corresponding Call to Function is as follows
//Order Call
add_action( 'wp_ajax_pending_order', array( &$this, 'create_order'));
function create_order()
{
global $woocommerce, $wp;
// Security check
check_ajax_referer( 'ajax_post_validation', 'security' );
//Getting Product ID
$id = $_POST['prod_id'];
// create order
$address = array(
'first_name' => 'Iskandariya',
'last_name' => 'Solutions',
'company' => 'Iskandariya.Solutions',
'phone' => '+91-9999999999',
'address_1' => 'Chandigarh',
'address_2' => 'Mohali,Punjab',
'city' => 'Chandigarh',
'state' => 'PB',
'postcode' => '160001',
'country' => 'IN'
);
$order_data = array(
'customer_id' => get_current_user_id()
);
$order = wc_create_order($order_data);
$order->add_product( get_product( $id ), 1 ); //(get_product with id and next is for quantity)
$order->set_address( $address, 'billing' );
$order->set_address( $address, 'shipping' );
$order->calculate_totals();
wp_die();
}
In a way thank you for not responding it took me longer but I learnt on developing Plugin for Wordpress and alot more.