I created an empty module using these instructions http://doc.prestashop.com/display/PS16/Creating+a+first+module, then I added an Hook Function linked to Payment
public function hookactionPaymentConfirmation($params)
{
//the thing you want to do when the hook's executed goes here
$order = new Order((int)$params['id_order']);
$address = new Address((int)$order->id_address_delivery);
$state = new State((int)$address->id_state);
$country = new Country((int)$state->id_country);
$product_list = $order->getOrderDetailList();
$prodotti = '[';
foreach ($product_list as $product)
{
if ($prodotti != '[')
{
$prodotti .= ',';
}
$prodotti .= '{"codice": "'.$product['product_reference'].'", "qta": '.$product['product_quantity'].'}';
}
$prodotti .= ']';
//CONTACT THE DROPSHIPPER API
}
If you need to verify the stock availability you need to override the Cart Class for the function checkProductsAccess and remove the product from the cart if it's not available
public function checkProductsAccess()
{
parent::checkProductsAccess();
foreach ($this->getProducts() as $product) {
//CHECK AVAILABILITY
if ($avail = 0)
{
$this->deleteProduct($product["id_product"]);
return $product['id_product'];
}
}
return false;
}
0 commenti:
Post a Comment