Get Product Amount


/ Published in: PHP
Save to your folder(s)

PHP function that returns product amount wich can be used in any custom development


Copy this code and paste it in your HTML
  1. function fn_hw_product_stock($product_id){
  2. $values = db_get_row("SELECT amount, tracking FROM ?:products WHERE product_id = ?s LIMIT 1", $product_id);
  3. $amount = $values['amount'];
  4. if($values['tracking'] == 'O'){
  5. $options_amount = db_get_row("SELECT SUM(amount) as amount FROM ?:product_options_inventory WHERE product_id = ?s LIMIT 1", $product_id);
  6. $amount = $options_amount['amount'];
  7. }
  8. return $amount;
  9. }

URL: https://www.hungryweb.net/cs-cart-addons/

Report this snippet


Comments


You need to login to view comments.