Jump to content



Member Since 10 Dec 2017
Offline Last Active Mar 23 2018 02:15 PM

Posts I've Made

In Topic: Excluding Products Without Image

19 March 2018 - 05:12 PM

Just check cscart_images_links table with object_id = PRODUCT_ID and object_type = 'product'


If image_id or detailed_id parameters. At least one of them should not be empty

Like this?

$condition .= db_quote(
            ' AND (CASE products.tracking' .
            '   WHEN ?s THEN inventory.amount > products.min_stock' .
            '   WHEN ?s THEN products.amount > products.min_stock' .
			'   WHEN ?s THEN (SELECT ?:images_links.image_id FROM ?:images_links WHERE ?:images_links.object_id=products.product_id AND ?:images_links.object_type = "product") != 0' .
			'   WHEN ?s THEN (SELECT ?:images_links.detailed_id FROM ?:images_links WHERE ?:images_links.object_id=products.product_id AND ?:images_links.object_type = "product") != 0' .
            '   ELSE 1' .
            ' END)',

In Topic: Hooks For "editing Profile"-Page

17 March 2018 - 01:07 PM

Second path should be



Hi again,


How do I fetch the user_id when using the frontend management page?

<div class="statistics-box">
	<div class="statistics-body">
		<p class="strong">Equivalent RetailEdge ID:</p> <p>{$custID} </p>

if (!defined('BOOTSTRAP')) { die('Access denied'); }

use Tygh\Registry;

$custID = db_get_field('SELECT cust_id FROM ?:users WHERE user_id=?i', $_REQUEST['user_id']);

if (!empty($custID)) {
    Registry::get('view')->assign('custID', $custID);

It isn't fetching the cust_id field (this code works for the backend panel where the same thing is done). Is the $_REQUEST parameter wrong?

In Topic: Hooks For "editing Profile"-Page

14 March 2018 - 04:42 PM

Please check available hooks in the following template:




Unfortunately, the Usergroups tab does not contain hooks

Thank you.


However, my currently selected theme does not have these file directories. How do I work around this? Is this a problem?


Also, I've never done frontend addons before. Is the following directory structure correct?

1: app/addons/ADDON/controllers/frontend/profiles.post.php

2:  design/backend/templates/addons/ADDON/hooks/profiles/account_update.post.tpl

In Topic: Change Min Stock Qty From 0

21 February 2018 - 05:32 PM

If you mean products.post.php (not manage.post.php), please use

$product_stock = db_get_field('SELECT min_stock FROM ?:products WHERE product_id= ?i', $_REQUEST['product_id']);

As for hook, I cannot find such hook in 4.7.1 version. Where is it located?


Inside my products.post.php, my method for updating the stock looks like this: 

$product_id = $_REQUEST['product_id'];

$product_stock = db_get_field('SELECT min_stock FROM ?:products WHERE product_id=?i', $_REQUEST['product_id']);

if (!empty($product_stock)) {
    Registry::get('view')->assign('product_stock', $product_stock);

if(isset ($_POST['newProductStock'])){

function updateStock($value){
  $data = array(
    'min_stock' => $value
  db_query("UPDATE ?:products SET ?u WHERE product_id=".$product_id."", $data);
  $product_stock = $value;
  Registry::get('view')->assign('product_stock', $product_stock);

Yet the min_stock when editing a specific product is not altered. Is there an issue with my code? Suspecting it's got to do with my query formulation...

In Topic: Change Min Stock Qty From 0

03 February 2018 - 08:43 AM

Thank you, Oleg. It's working as expected!


When managing/editing each individual product, I need to get the product_id value for a database lookup. In my manage.post.php file (absed on views->products->manage.tpl),  how do I get the product id of the product I'm managing?


Code snippet from manage.post.php:

$product_stock = db_get_field('SELECT min_stock FROM ?:products WHERE product_id='. $product_id .'');

I suspect that $product_idm will be undefined, as I haven't defined it earlier in my PHP-script.


Hook-function in the addons func.php:

function fn_minimum_stock_get_product_stock_pre($product_id){
	$auth = $_SESSION['auth'];
	if (!empty($auth['user_id'])) {
		$product_stock = db_get_field('SELECT min_stock FROM ?:products WHERE product_id=?i', $product_id);