X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   General questions (X-Cart 5) (https://forum.x-cart.com/forumdisplay.php?f=66)
-   -   Where is the function getTotal() declared? (https://forum.x-cart.com/showthread.php?t=74178)

Ed B. 07-08-2016 08:02 AM

Where is the function getTotal() declared?
 
This question is related to another question of mine.
I see that the function getTotal() is used in many places including
classes/XLite/View/Minicart.php, but the only place where I found it
declared so far is classes/XLite/Module/CDev/XPaymentsConnector/Model/Order.php.

I suppose I am missing something, but where?

qualiteam 07-08-2016 09:41 AM

Re: Where is the function getTotal() declared?
 
When re-deploying, X-Cart 5.2.x auto-generates get* and set* methods for model properties. getTotal() translates to $this->total. You won't find these methods in the classes/ directory, but you will find them in the var/run/classes directory.

However, the upcoming X-Cart 5.3 won't autogenerate these methods anymore, so module authors will have to declare them manually.

Ed B. 07-10-2016 05:38 AM

Re: Where is the function getTotal() declared?
 
Thank you very much, I went through /var/run/classes, but I couldn't find where total() was declared. It would be nice if there were a documentation in KB that deals with this kind of thing. Anyway, would anyone know where I can find the function total() is declared?

cflsystems 07-10-2016 06:22 AM

Re: Where is the function getTotal() declared?
 
There is no function "total". "Total" is a field in table. When the object is built XC automatically creates getTotal and setTotal functions to read/write in this field.

So if you have TableA and field in it called "total"

$TableA->total;
$TableA->getTotal();
$tableA->setTotal();

all work with the field "total" from table "TableA"

Ed B. 07-11-2016 08:28 AM

Re: Where is the function getTotal() declared?
 
Thank you very much, this is now clear.


All times are GMT -8. The time now is 02:19 PM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.