Your Add-On Needs A New Hook In Cs-Cart. Post It Here.

[quote name='eComLabs' timestamp='1434029550' post='218433']

Functions which works with destinations do not have any hooks at all. Please check

[/quote]



I added hooks to the following functions:

fn_get_states

fn_get_countries

fn_get_destinations

fn_get_avilable_desintaion



Will be included in 4.3.4 or 4.3.5

You can do the test of page_id in the hook.



A terrific enhancement for override hooks would be to have the original content available in a capture variable so you could (for example) in your override file:


{if $page_id == 123}
do this code
{else}
$smarty.capture.[hook_name]
{/if}

Hello.



Line 168 in /app/controllers/backend/cart.php



fn_set_hook('pre_get_carts', $params, $fields, $sortings);



Thank you

Robert

[quote name='soft-solid' timestamp='1436793075' post='222709']

Hello.



Line 168 in /app/controllers/backend/cart.php



fn_set_hook('pre_get_carts', $params, $fields, $sortings);



Thank you

Robert



[/quote]

Functions will be moved to fn.cart.php.

After the hooks are added I will let you know.

[quote name='imac' timestamp='1435701427' post='221142']

Will be there in 4.3.4 or 4.3.5

[/quote]



Awesome. Thanks!

In fn.init.php → fn_init_currency


function fn_init_currency($params, $area = AREA)
{
$_params = array();
if (fn_allowed_for('ULTIMATE:FREE')) {
$_params['only_primary'] = 'Y';
} elseif ($area == 'C') {
$_params['status'] = array('A', 'H');
} else {
$_params['status'] = array('A', 'H');
}
$currencies = fn_get_currencies_list($_params, $area, CART_LANGUAGE);

fn_set_hook('init_currency', $params);

[quote name='Elsherif' timestamp='1439272538' post='226292']

In fn.init.php → fn_init_currency


function fn_init_currency($params, $area = AREA)
{
$_params = array();
if (fn_allowed_for('ULTIMATE:FREE')) {
$_params['only_primary'] = 'Y';
} elseif ($area == 'C') {
$_params['status'] = array('A', 'H');
} else {
$_params['status'] = array('A', 'H');
}
$currencies = fn_get_currencies_list($_params, $area, CART_LANGUAGE);

fn_set_hook('init_currency', $params);


[/quote]



Why do you need hook in fn_init_currency? Maybe it would be more appropriate to have hook in fn_get_currencies_list?

[quote name='Elsherif' timestamp='1439272538' post='226292']

In fn.init.php → fn_init_currency



[/quote]



Link to a discussion is always welcom:) How To Change Store Currency From Addon - Hints & Modifications - CS-Cart Community Forums



Ok will investigate this and add required hooks.

[quote name=‘imac’ timestamp=‘1439325555’ post=‘226434’]

Link to a discussion is always welcom:) http://forum.cs-cart…__fromsearch__1



Ok will investigate this and add required hooks.

[/quote]



Sorry … I was just about to post it but you found it anyway :grin:

Hi,



Could we have a hook in fn_auth_routines so we can specify which field it should look for a username?



At the moment its hardcoded to email, but we would like this to change to user_login and be able to login with both email and username.

[quote name='Elsherif' timestamp='1439272538' post='226292']

In fn.init.php → fn_init_currency


function fn_init_currency($params, $area = AREA)
{
$_params = array();
if (fn_allowed_for('ULTIMATE:FREE')) {
$_params['only_primary'] = 'Y';
} elseif ($area == 'C') {
$_params['status'] = array('A', 'H');
} else {
$_params['status'] = array('A', 'H');
}
$currencies = fn_get_currencies_list($_params, $area, CART_LANGUAGE);

fn_set_hook('init_currency', $params);


[/quote]



Will be there in 4.3.5 only. That's because 4.3.4 branch is closed for new changes already.

[quote name='websitedesign' timestamp='1439997609' post='227246']

Hi,



Could we have a hook in fn_auth_routines so we can specify which field it should look for a username?



At the moment its hardcoded to email, but we would like this to change to user_login and be able to login with both email and username.

[/quote]

I've created a task.

Will be there in 4.3.5 only. That's because 4.3.4 branch is closed for new changes already.

Great ... thanks :)

Not a new hook, just an extra parameter added to an existing one.

save_cart should also include the $user_type variable.

So

fn_set_hook('save_cart', $cart, $user_id, $type);

would become

fn_set_hook('save_cart', $cart, $user_id, $type, $user_type);

in app/functions/fn.cart.php:1472

Thanks!

$user_type = db_get_field("SELECT user_type FROM ?:users WHERE user_id=?i", $user_id);
if( $user_type === false )
  $user_type = 'C';

Note that a cart can be saved for a user that does not have an account. You can alternatively do this via

$user_type = empty($_SESSION['auth']['user_type']) ? 'C' : $_SESSION['auth']['user_type'];

But this would NOT work when admin is acting on behalf of.

A hook should be considered like an API. If it's easy to get the info without adding a parameter, one should approach it that way.

Hi tbirnseth, thanks for your reply.

I have used the code you provided, although it does require an extra unnecessary database query when the data is already readily available in the code therefore it would still make sense for it to be passed through in the hook.

-------------------------------------------------------------

Another hook suggestion for fn_create_order_details:

v4.3.1 app/functions/fn.cart.php:1093

fn_set_hook('create_order_details', $order_id, $cart, $order_details);

Thanks

Don't think user_type is part of the order_details. Maybe but I wouldn't rely on it given the query will address it regardless of whether it is the user manipulating the order or an admin acting on behalf of....

User_data is available in a cart. But once an order is created, I think the only 'user_data' that remains with the order is the user_id.

Need a template hook to minipulate the product price wherever it may show up. Currently in some of the templates, overriding the price includes overriding other hooks.

There are already 2 hooks in common/product_data.tpl for product prices:

{hook name="products:old_price"}
{hook name="products:prices_block"}

What additional hooks do you require for product price? I think most all displays of product price uses {$product_data.price} which those hooks can modify.

These are currently the hooks I have to use and they use {$smarty.capture.$price nofilter}. The first one is the main concern. The others just interfere with other data. I will look into the hook you provided.


blocks/product_templates/default_template.tpl

{hook name=“products:view_main_info”}

blocks/list_templates/compact_list.tpl
{hook name=“products:product_compact_list”}

blocks/list_templates/grid_list.tpl
{hook name=“products:product_multicolumns_list”}

blocks/list_templates/links_thumb.tpl
{hook name=“products:product_thumbnail_list”}

blocks/list_templates/products_list.tpl
{hook name=“products:product_block_content”}
blocks/list_templates/simple_list.tpl
No hooks
blocks/list_templates/small_items.tpl
{hook name=“products:product_small_item”}

Edit: Yep, looks like the prices_block hook is the way to go.