Jump to content

  • You cannot start a new topic
  • You cannot reply to this topic

Your Add-On Needs A New Hook In Cs-Cart. Post It Here. Rate Topic   * * * * * 1 votes

 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 11248 posts

Posted 25 July 2016 - 09:44 PM #81

Please add the following hook to fn_update_order_payment_info() function.

just before the foreach of the pp_response, please add the following hook:

fn_set_hook('order_payment_info_pre', $order_id, $payment_info, $pp_response);
foreach ($pp_response as $k => $v) {

 

This is because there's no way to reset or clear out any payment_info data that was placed the checkout process.  I.e. things like a 'nonce' from a payment provider where iFrames are used to capture data and the cc data is tokenized.

 

I realize this is an 'update' routine, but this is the first opprortunity to clean up the payment_info after the payment script completes.  This really should just SET the payment info to the pp_response values versus merging pp_response with stored payment_info.  But the hook can help accomplish the same thing without breaking any existing code or payment methods expectations.


EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.


 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 11248 posts

Posted 26 July 2016 - 10:27 PM #82

Please add the following hook (and corrected code) in fn.cart.php in the fn_change_order_status() function.
 
This change will allow support of marketplace payment providers who require a separate transaction for each vendor (I.e. Braintree Marketplace).
 
foreach ($child_ids as $child_order_id) {
  // EZms add hook
  $change_children_status = true;
  $child_status = $status_to;
  fn_set_hook('children_order_status', $order_id, $child_order_id, $child_status, $change_children_status);
  if( $change_children_status ) {
    $_res = fn_change_order_status($child_order_id, /*EZms change */$child_status, '', $force_notification, $place_order);
    $res = $res && $_res;
  }
  // EZms end
}
 
Note that the code
 
$res = $res && $_res;
Must be inside the loop otherwise $res will be returned based only on the last execution of the loop which I don't believe to be correct.  I believe the desire is to return false if ANY failure occurred, not just if the last fn_change_order_status() failed.

EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.


 
  • imac
  • Head of Product
  • CS-Cart Architects
  • Join Date: 22-Nov 05
  • 2046 posts

Posted 29 July 2016 - 01:48 PM #83

Please add the following hook (and corrected code) in fn.cart.php in the fn_change_order_status() function.
 
This change will allow support of marketplace payment providers who require a separate transaction for each vendor (I.e. Braintree Marketplace).
 

foreach ($child_ids as $child_order_id) {
  // EZms add hook
  $change_children_status = true;
  $child_status = $status_to;
  fn_set_hook('children_order_status', $order_id, $child_order_id, $child_status, $change_children_status);
  if( $change_children_status ) {
    $_res = fn_change_order_status($child_order_id, /*EZms change */$child_status, '', $force_notification, $place_order);
    $res = $res && $_res;
  }
  // EZms end
}
 
Note that the code
 
$res = $res && $_res;
Must be inside the loop otherwise $res will be returned based only on the last execution of the loop which I don't believe to be correct.  I believe the desire is to return false if ANY failure occurred, not just if the last fn_change_order_status() failed.

 

 

We will investigate these changes, and if there more convenient solution I will ask for your feedback.


Ilya Makarov,
CS-Cart Architect Team
Suggest and vote for new features | Report a bug

 
  • imac
  • Head of Product
  • CS-Cart Architects
  • Join Date: 22-Nov 05
  • 2046 posts

Posted 29 July 2016 - 01:58 PM #84

Please add a hook that either encloses or prepends to the summary order total in orders/details.tpl.  Goal is to be able to add an item (such as a fee or additional charge) to the list of fees just above the total.  Right now, the only way is to use the totals.pre.tpl which places it at the top above the descriptive info rather than ahead of the total with the rest of the fees.  If enclosing, name it something like orders:summary_total and if not something like orders:additional_fees.

 

As I can see there is "orders:totals_content" hook that should solve you problem.


Ilya Makarov,
CS-Cart Architect Team
Suggest and vote for new features | Report a bug

 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 11248 posts

Posted 29 July 2016 - 08:02 PM #85

As I can see there is "orders:totals_content" hook that should solve you problem.

Unfortunately this hook is in the wrong place.  It is after the totals so any added charges will not show before the total so things are in proper order.


EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.


 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 11248 posts

Posted 29 July 2016 - 08:12 PM #86

Deleted request


EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.


 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 11248 posts

Posted 01 August 2016 - 08:55 PM #87

One hook request and one bug...

In design/backend/templates/views/companies/balance.tpl

 

First the bug: You allow for extending the table via hooks in the upper part of the template.  However, in the 'notes' area (where the colspan="8") doesn't account for any additional columns that may have been added.  With the new hook the bug can be corrected as well as enabling additional data to be displayed.

 

The hook request is to place a hook around the 'tr' for the notes area so this expanded area can be used to display other data.  Suggest:

<tr id="payout_note_{$smarty.foreach.payouts.iteration}".....>
{hook name="companies:payout_note"}
  <td....>
  ....
  </td>
{/hook}
</tr>

EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.


 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 11248 posts

Posted 01 August 2016 - 08:59 PM #88

In fn.multivendor.php, please add the following hook just before the return of the fn_companies_get_payouts() function.

fn_set_hook('mve_companies_get_payouts_post', $payouts, $params, $total);

This will allow an addon developer to unserialize any encoded fields they may have added to the vendor_payouts table before the data is returned to the caller (I.e. the companies.balance page).


EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.


 
  • mschekotov
  • Architect
  • CS-Cart Architects
  • Join Date: 06-Aug 15
  • 12 posts

Posted 09 August 2016 - 12:09 PM #89

Please add the following hook to fn_update_order_payment_info() function.

just before the foreach of the pp_response, please add the following hook:

fn_set_hook('order_payment_info_pre', $order_id, $payment_info, $pp_response);
foreach ($pp_response as $k => $v) {

 

 

There will be a hook in the next release:

    /**
     * Executes right before putting the order payment info in the database, allowing you to modify the SQL query.
     *
     * @param int   $order_id     Order identifier
     * @param array $pp_response  Response from payment processor
     * @param array $payment_info Payment processor response merged with the stored payment information
     * @param array $data         Order data to be put in the database
     */
    fn_set_hook('update_order_payment_info', $order_id, $pp_response, $payment_info, $data);

    db_query("REPLACE INTO ?:order_data ?e", $data);

Michael Schekotov,
CS-Cart Architect Team
Report a bug


 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 11248 posts

Posted 09 August 2016 - 06:21 PM #90

 

There will be a hook in the next release:

    /**
     * Executes right before putting the order payment info in the database, allowing you to modify the SQL query.
     *
     * @param int   $order_id     Order identifier
     * @param array $pp_response  Response from payment processor
     * @param array $payment_info Payment processor response merged with the stored payment information
     * @param array $data         Order data to be put in the database
     */
    fn_set_hook('update_order_payment_info', $order_id, $pp_response, $payment_info, $data);

    db_query("REPLACE INTO ?:order_data ?e", $data);

That's not what I asked for. 

 

There is no need to rebuild the $data element or pass it in the hook since it's created from the parameters that I originally requested.  Everything that could be done within the hook you are implementing can be done a lot easier by adjusting the incoming parameters in the position I requested.

 

As described, the goal was to cleanup (or remove) the $payment_info that was stored at the time of the order creation and to reformat the data to make it more presentable in the UI.

 

With the hook you provide we now have to clean up the information AND recreate the $data element.  It is simply not what was requested.

 

It is just as effective and a lot simpler to do it the way I requested it without changing the name of the hook, the order of the parameters, and the position of the hook.

 

You also changed the name and I had labeled it 'pre' precisely because as requested it is a pre-processing hook. 

 

So would you please just add the hook with the name and parameters I requested and in the position I requested it so I don't have to go back and re-engineer a solution that is already simple and functional?

 

You can leave your new hook for those who want to go to that work but please add the 'order_payment_info_pre' hook that I requested.


EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.


 
  • mschekotov
  • Architect
  • CS-Cart Architects
  • Join Date: 06-Aug 15
  • 12 posts

Posted 10 August 2016 - 07:23 AM #91

You also changed the name and I had labeled it 'pre' precisely because as requested it is a pre-processing hook.

 

We have naming conventions regarding new hooks. One of them is that the hook name must include the function name it is used in.

Also, _pre suffix is to be used for the hook that is called at the very beginning of the function.

 

So, unfortunately, the name order_payment_info_pre can't be used, but the hook can be named update_order_payment_info_before_processing_response.

If this name suits your needs, the new hook will be added.


Michael Schekotov,
CS-Cart Architect Team
Report a bug


 
  • aksenovaa
  • Member
  • Trial users
  • Join Date: 22-Jun 16
  • 26 posts

Posted 20 August 2016 - 06:22 AM #92

Please add the following hook to design/themes/responsive/templates/index.tpl template to use custom code to output a favicon. Now brought code using meta.post.tpl, but the lack of that is code from standard template:

{include file="meta.tpl"}
<link href="{$logos.favicon.image.image_path|fn_query_remove:'t'}" rel="shortcut icon" type="{$logos.favicon.image.absolute_path|fn_get_mime_content_type}" />
{include file="common/styles.tpl" include_dropdown=true}

For such a small change to do the overwrite index.tpl to make no sense, especially since it will prevent the proper update of the system. You need to add only two lines of code in the standard template

	{hook name="index:favicon"}
		<link href="{$logos.favicon.image.image_path|fn_query_remove:'t'}" rel="shortcut icon" type="{$logos.favicon.image.absolute_path|fn_get_mime_content_type}" />
	{/hook}


 
  • imac
  • Head of Product
  • CS-Cart Architects
  • Join Date: 22-Nov 05
  • 2046 posts

Posted 23 August 2016 - 01:48 PM #93

 

Please add the following hook to design/themes/responsive/templates/index.tpl template to use custom code to output a favicon. Now brought code using meta.post.tpl, but the lack of that is code from standard template:

{include file="meta.tpl"}
<link href="{$logos.favicon.image.image_path|fn_query_remove:'t'}" rel="shortcut icon" type="{$logos.favicon.image.absolute_path|fn_get_mime_content_type}" />
{include file="common/styles.tpl" include_dropdown=true}

For such a small change to do the overwrite index.tpl to make no sense, especially since it will prevent the proper update of the system. You need to add only two lines of code in the standard template

	{hook name="index:favicon"}
		<link href="{$logos.favicon.image.image_path|fn_query_remove:'t'}" rel="shortcut icon" type="{$logos.favicon.image.absolute_path|fn_get_mime_content_type}" />
	{/hook}

Hi aksenovaa,

 

Can you please let me know why would you like to change the favicon? You need any extra attributes or there is some issue with favicon path?


Ilya Makarov,
CS-Cart Architect Team
Suggest and vote for new features | Report a bug

 
  • aksenovaa
  • Member
  • Trial users
  • Join Date: 22-Jun 16
  • 26 posts

Posted 24 August 2016 - 07:45 PM #94

Hi aksenovaa,

 

Can you please let me know why would you like to change the favicon? You need any extra attributes or there is some issue with favicon path?

I do not like the current code for the favicon.For example, I need to get this code:

<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png?v=RyyRmKA9O8">
<link rel="icon" type="image/png" href="/favicon-32x32.png?v=RyyRmKA9O8" sizes="32x32">
<link rel="icon" type="image/png" href="/favicon-16x16.png?v=RyyRmKA9O8" sizes="16x16">
<link rel="manifest" href="/manifest.json?v=RyyRmKA9O8">
<link rel="mask-icon" href="/safari-pinned-tab.svg?v=RyyRmKA9O8" color="#5bbad5">
<link rel="shortcut icon" href="/favicon.ico?v=RyyRmKA9O8">
<meta name="msapplication-TileColor" content="#00a300">
<meta name="msapplication-TileImage" content="/mstile-144x144.png?v=RyyRmKA9O8">
<meta name="theme-color" content="#ffffff">

But in order to withdraw, you must replace the entire design/themes/responsive/templates/index.tpl via overwrite. 

I went through meta.post.tpl. But it remains unnecessary code:

<link href="http://captor-shoes.ru/images/logos/1/favicon_hg2x-h5_0sw4-p1.ico" rel="shortcut icon" type="image/x-icon" />


 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 11248 posts

Posted 26 August 2016 - 05:53 PM #95

So, unfortunately, the name order_payment_info_pre can't be used, but the hook can be namedupdate_order_payment_info_before_processing_response.

 

Seems like "conventions" are made up as we go along.  As I've looked at hooks, a pre hook is used before any queries (update, insert, replace) and post are used after the queries (queries that are modifying the requested data, not related info).

 

So where are these "conventions" documented so that when we request things we can have some chance of them actually getting done as we request?


EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.


 
  • ikoshkin
  • Tech Writer
  • CS-Cart Architects
  • Join Date: 25-Nov 15
  • 290 posts

Posted 29 August 2016 - 08:53 AM #96

Since the question concerns documentation, please allow me to answer instead of Michael.
 
So far the conventions regarding hooks (i.e. their names, their position in the code, the availability and order of arguments, etc.) have existed as an internal document in CS-Cart repository. The document in its current state is a bit older than this topic. These conventions were established over the course of CS-Cart development—that's why some older hooks may not fully comply with them.
 
Thank you for bringing this up—we'll make the conventions available as a part of our Coding Standards in a few days. I'll reply to this topic again when it's done.



 
  • imac
  • Head of Product
  • CS-Cart Architects
  • Join Date: 22-Nov 05
  • 2046 posts

Posted 29 August 2016 - 11:42 AM #97

 

I do not like the current code for the favicon.For example, I need to get this code:

<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png?v=RyyRmKA9O8">
<link rel="icon" type="image/png" href="/favicon-32x32.png?v=RyyRmKA9O8" sizes="32x32">
<link rel="icon" type="image/png" href="/favicon-16x16.png?v=RyyRmKA9O8" sizes="16x16">
<link rel="manifest" href="/manifest.json?v=RyyRmKA9O8">
<link rel="mask-icon" href="/safari-pinned-tab.svg?v=RyyRmKA9O8" color="#5bbad5">
<link rel="shortcut icon" href="/favicon.ico?v=RyyRmKA9O8">
<meta name="msapplication-TileColor" content="#00a300">
<meta name="msapplication-TileImage" content="/mstile-144x144.png?v=RyyRmKA9O8">
<meta name="theme-color" content="#ffffff">

But in order to withdraw, you must replace the entire design/themes/responsive/templates/index.tpl via overwrite. 

I went through meta.post.tpl. But it remains unnecessary code:

<link href="http://captor-shoes.ru/images/logos/1/favicon_hg2x-h5_0sw4-p1.ico" rel="shortcut icon" type="image/x-icon" />

Ok thank you, will add this in next release.


Ilya Makarov,
CS-Cart Architect Team
Suggest and vote for new features | Report a bug

 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 11248 posts

Posted 29 August 2016 - 05:58 PM #98

Since the question concerns documentation, please allow me to answer instead of Michael.
 
So far the conventions regarding hooks (i.e. their names, their position in the code, the availability and order of arguments, etc.) have existed as an internal document in CS-Cart repository. The document in its current state is a bit older than this topic. These conventions were established over the course of CS-Cart development—that's why some older hooks may not fully comply with them.
 
Thank you for bringing this up—we'll make the conventions available as a part of our Coding Standards in a few days. I'll reply to this topic again when it's done.

 

That's all well and good.  The trouble is one of timing.  We do development work for a client.  A new hook is determined to be the best long term solution for the client.  We modify the file and add the hook (template or php).  We then submit a hook request with the hope that when the client upgrades, the hook will be in place and we won't have to go back in and add it (OR CHANGE IT).  We also try to tell you why we're requesting the hook and what we expect to do within the hook to ensure we're all on the same page.

 

When you change the names or parameters it just breaks what we've done.  Out of the tons of hooks I've requested, very few are implemented as we've requested.  There is always some subtle difference in either the order of parameters, the name, etc.

 

We've used hooks in cs-cart since V2.0. They have evolved and yes, some even have naming standards.  However, they are applied inconsistently.  I.e. not all _pre hooks happen at the beginning of a function.  Generally a _pre hook has been used before a query to modify what the query may return.  And a _post hook happens after the query to modify the results.  Hence we asked for a _pre hook before the data is saved and you gave us a _post hook after the query was executed which would cause us to re-calculate the data and re-execute the query which is all very wasteful.

 

It is time consuming when you change names or order of parameters from what was requested especially given that many times, these changes seem to be arbitrary and feel more like developer-de-jure type of decisions.   Alternatively, if you won't do as requested, maybe you should open a dialog to determine a solution versus just doing something that doesn't address the need.


EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.


 
  • imac
  • Head of Product
  • CS-Cart Architects
  • Join Date: 22-Nov 05
  • 2046 posts

Posted 30 August 2016 - 08:29 AM #99

That's all well and good.  The trouble is one of timing.  We do development work for a client.  A new hook is determined to be the best long term solution for the client.  We modify the file and add the hook (template or php).  We then submit a hook request with the hope that when the client upgrades, the hook will be in place and we won't have to go back in and add it (OR CHANGE IT).  We also try to tell you why we're requesting the hook and what we expect to do within the hook to ensure we're all on the same page.

 

When you change the names or parameters it just breaks what we've done.  Out of the tons of hooks I've requested, very few are implemented as we've requested.  There is always some subtle difference in either the order of parameters, the name, etc.

 

We've used hooks in cs-cart since V2.0. They have evolved and yes, some even have naming standards.  However, they are applied inconsistently.  I.e. not all _pre hooks happen at the beginning of a function.  Generally a _pre hook has been used before a query to modify what the query may return.  And a _post hook happens after the query to modify the results.  Hence we asked for a _pre hook before the data is saved and you gave us a _post hook after the query was executed which would cause us to re-calculate the data and re-execute the query which is all very wasteful.

 

It is time consuming when you change names or order of parameters from what was requested especially given that many times, these changes seem to be arbitrary and feel more like developer-de-jure type of decisions.   Alternatively, if you won't do as requested, maybe you should open a dialog to determine a solution versus just doing something that doesn't address the need.

 

Tony, I do understand your concern and here is what we are going to do.

1) Publish the hook instructions in order to minimise this "When you change the names or parameters it just breaks what we've done."

2) Provide access to developers for CS-Cart repo in order them to be able to submit pull request with new hook. Here we will also publish a tutorial on how to submit a hook to CS-Cart repo.

 

I hope if instruction from p.1 will be clear this will significantly decrease the time developers spent for asking for a new hook.


Ilya Makarov,
CS-Cart Architect Team
Suggest and vote for new features | Report a bug

 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 11248 posts

Posted 30 August 2016 - 06:03 PM #100

That will be a help.  The whole goal is to do the work once and have the next upgrade of the system incorporate it.


EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.