Understanding The Flow Of The Product Page (Amount Section)

Hi,

I am a PHP programmer by nature. I am new with CS-Cart. I am trying hard to understand the flow of the product page, and mainly the product amount section, since I need some alterations here.

This is the file I am working in:

\design\themes\nrp\templates\addons\my_changes\blocks\product_templates\nrp_template.tpl

This is the part of the code I mean:

{if $capture_options_vs_qty}{capture name="product_options"}{$smarty.capture.product_options nofilter}{/if}

{assign var="product_amount" value="product_amount_`$obj_id`"}
{$smarty.capture.$product_amount nofilter}
{assign var="qty" value="qty_`$obj_id`"}
{$smarty.capture.$qty nofilter}
{assign var="min_qty" value="min_qty_`$obj_id`"}
{$smarty.capture.$min_qty nofilter}

{if $capture_options_vs_qty}{/capture}{/if}
In which file is the info retrieved from the database?
In which file is the part that handles what is shown on screen?
And are there more files which are depending on this?
In other words... what is the flow from database to what is shown on screen?

Hi,

I am a PHP programmer by nature. I am new with CS-Cart. I am trying hard to understand the flow of the product page, and mainly the product amount section, since I need some alterations here.

This is the file I am working in:

\design\themes\nrp\templates\addons\my_changes\blocks\product_templates\nrp_template.tpl

This is the part of the code I mean:

{if $capture_options_vs_qty}{capture name="product_options"}{$smarty.capture.product_options nofilter}{/if}

{assign var="product_amount" value="product_amount_`$obj_id`"}
{$smarty.capture.$product_amount nofilter}
{assign var="qty" value="qty_`$obj_id`"}
{$smarty.capture.$qty nofilter}
{assign var="min_qty" value="min_qty_`$obj_id`"}
{$smarty.capture.$min_qty nofilter}

{if $capture_options_vs_qty}{/capture}{/if}
In which file is the info retrieved from the database?
In which file is the part that handles what is shown on screen?
And are there more files which are depending on this?
In other words... what is the flow from database to what is shown on screen?

Hello!

The data from database is retrieved in the particular controller, in your case it is app/controllers/frontend/products.php

For example, mode 'view': firstly, we get the product data:

$product = fn_get_product_data(
    $_REQUEST['product_id'],
    $auth,
    CART_LANGUAGE,
    '',
    true,
    true,
    true,
    true,
    fn_is_preview_action($auth, $_REQUEST),
    true,
    false,
    true
);

make the necessary changes and transfer data to the templater:

Tygh::$app['view']->assign('product', $product);

After that the product variable is accessable in the template.

@oleg:

Thanks! That really helped me in understanding where the data comes from.

But please explain this:

{assign var="qty" value="qty_`$obj_id`"}
{$smarty.capture.$qty nofilter}

What does it say?

Where is the file that handles the html to the screen?

/* edit */

I have found the file that handles the html:

\design\themes\nrp\templates\views\products\components\products_qty_discounts.tpl

But now I want to override this part. Do I use this template of should I make one myself? And if so, where should I put my own file?

(what is the best procedure?)

It depends on if what you want to change is inside a hook or not. Read up on the documentation to get a better understanding. http://docs.cs-cart.com/4.3.x/developer_guide/core/coding_standards/hooks.html

Product information which is called by the capture is generated in the following file:

design/themes/YOUR_THEME/templates/common/product_data.tpl

Then you should just display necessary data in your template