$message .= '<td>' . StockAvailable::getQuantityAvailableByProduct($prod['product_id'], $prod['product_attribute_id']) . '</td>'; } $message .= '</tr>'; } $message .= '</table>'; print $message; } break; case 'productSupplierPrice': /* If we have called the script with a term to search */ if (Tools::isSubmit('id_product') && Tools::isSubmit('id_product_attribute')) { $id_product = Tools::getValue('id_product'); $id_product_attribute = Tools::getValue('id_product_attribute'); $id_currency = Tools::getValue('id_currency', false) ? Tools::getValue('id_currency') : Configuration::get('PS_CURRENCY_DEFAULT'); /* Prices of all suppliers for the product */ $supplier_prices = ErpProductSupplier::getAllProductSupplierPrice($id_product, $id_product_attribute, true); if (!empty($supplier_prices)) { echo '<table class="table">'; foreach ($supplier_prices as $price) { /* If supplier price = 0 we get the basic one */ if ($price['product_supplier_price_te'] == '0.000000') { $wholesale_price = Stock::getWholesalePrice($id_product, $id_product_attribute); } else { $wholesale_price = $price['product_supplier_price_te']; } /* Write of the HTML table */ echo '<tr> <td>' . $price['supplier_name'] . '</td> <td>' . number_format($wholesale_price, 2, '.', ' ') . '€</td> </tr>'; }
public function ajaxGetProductSupplierPrice() { // If we have called the script with a term to search if (Tools::isSubmit('id_product') && Tools::isSubmit('id_product_attribute')) { require_once _PS_MODULE_DIR_ . 'erpillicopresta/classes/ErpProductSupplier.php'; $id_product = Tools::getValue('id_product'); $id_product_attribute = Tools::getValue('id_product_attribute'); //$id_currency = Tools::getValue('id_currency', false) ? Tools::getValue('id_currency') : 1; /* Price for all suppliers for the product */ $supplier_prices = ErpProductSupplier::getAllProductSupplierPrice($id_product, $id_product_attribute, true); if (!empty($supplier_prices)) { echo '<table class="table">'; foreach ($supplier_prices as $price) { /* If supplier price = 0 we take the basic one */ if ($price['product_supplier_price_te'] == '0.000000') { $supplier_price = ErpStock::getWholesalePrice($id_product, $id_product_attribute); } else { $supplier_price = $price['product_supplier_price_te']; } /* writing of the HTML table */ echo '<tr> <td>' . $price['supplier_name'] . ' : </td> <td> ' . number_format($supplier_price, 2, '.', ' ') . '€</td> </tr>'; } echo '</table>'; } else { echo $this->l('No price found for this product!'); } } die; }