X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Modifying the design and features (X-Cart 5) (https://forum.x-cart.com/forumdisplay.php?f=56)
-   -   'Creating custom email notifications' dev doc (https://forum.x-cart.com/showthread.php?t=77548)

vasilis 01-22-2020 10:40 AM

'Creating custom email notifications' dev doc
 
In the 'Creating custom email notifications' dev. article, the Mailer::register function does not exist in the 5.4.x version, so, when trying to send email, I get a
Quote:

Call to undefined method XLite\Core\Mailer::register()
error message, so this article doesn't fit in 5.4.x version.

The related code, displayed in the article, concerns the Mailer extending and decorating class:
PHP Code:

<?php

namespace XLite\Module\XCExample\EmailDemo\Core;

/**
 * Mailer core class
 */
abstract class Mailer extends \XLite\Core\Mailer implements \XLite\Base\IDecorator
{
    public static function 
sendEmailDemoMessage($to$body '')
    {
        static::
register([
            
'subject' => 'Demo notification',        
            
'body' => $body,
        ]);

        static::
compose(
            
'DemoMail',
            static::
getSiteAdministratorMail(),
            
$to,
            
'modules/XCExample/EmailDemo/message',
            array(),
            
true,
            \
XLite::CUSTOMER_INTERFACE
        
);

        return static::
getMailer()->getLastError();
    }
}



Would there be another method substituting register() method for 5.4.x, or the related code is different in other places as well, compared to the code presented in the article?

cflsystems 01-22-2020 11:05 AM

Re: 'Creating custom email notifications' dev doc
 
5.4.x made significant changes to how emails are handled. It is very different from 5.3.x now.
I suggest you take a look at some of the XC own modules to get an idea what/how to do it now.
For example the "Contact Us" module

vasilis 01-22-2020 11:17 PM

Re: 'Creating custom email notifications' dev doc
 
So, I guess it would be a good idea for Qualiteam to mark each developer's article with the X-Cart versions that it is compatible with (like they have done in a couple of articles). Of course, the best would be for them to try and fill-in the different development approach for a later version.

webtoolsoffers 01-23-2020 01:29 AM

Re: 'Creating custom email notifications' dev doc
 
The nice one information which you have to share on this site.

cflsystems 01-23-2020 05:25 AM

Re: 'Creating custom email notifications' dev doc
 
No that's actually not a good way. Marking an article that is for this or that version doesn't help match. It can be easily missed.
Best way is to have documentations for each branch so you can choose the branch - 5.3.x, 5.4.x, etc - and all articles related to it are in there. Of course for this to work we have to have a documentation first which is lacking big time with XC5 at the moment.

Triple A Racing 01-23-2020 07:05 AM

Re: 'Creating custom email notifications' dev doc
 
Quote:

Originally Posted by cflsystems
..... we have to have a documentation first which is lacking big time with XC5 at the moment

:mrgreen: :D/ Apparently... It's all currently being "assessed" by John Bingham. The 7th Earl of Lucan aka Lord Lucan. Don't hold your breath :wink:

vasilis 01-24-2020 12:58 PM

Re: 'Creating custom email notifications' dev doc
 
Getting out of subject here, but it goes without saying that there is no any proper dev. documentation for X-Cart. There are just bits and pieces of developing tips that are presented like a cooking recipe, without having presented the reason why a specific action is taken. Of course, if Qualiteam wanted, they would have done it, like it has been done in every other ecommerce platform. I am surprised though why an 'outsider' programmer hasn't tried to write a developer's guide book all these years.

cflsystems 01-24-2020 04:04 PM

Re: 'Creating custom email notifications' dev doc
 
Quote:

Originally Posted by vasilis
Getting out of subject here, but it goes without saying that there is no any proper dev. documentation for X-Cart. There are just bits and pieces of developing tips that are presented like a cooking recipe, without having presented the reason why a specific action is taken.



Sad but true... That's why I don't even go there. It takes lots of time to go through the code though and learn what/how it does in the beginning but after a while you get used to it.



Quote:

Originally Posted by vasilis
I am surprised though why an 'outsider' programmer hasn't tried to write a developer's guide book all these years.





1. Because it will be unofficial documentation.
2. Because XC changes its code so much and so often that writing and maintaining documentation will be a full time job.
3. Because no one will pay the "outsider" programmer to do that.
4. Because to write good documentation one has to have deep knowledge and understanding of what's there, how it works, what it does, etc. This goes back to #2.
5. Because it is not the "outside" programmer job to do this.

There's more reasons but why bother. This forum was a good source of documentation for XC4 however things changed with XC5. It is one thing to post few lines of code that will change product page for example (XC4) but for XC5 it may require to post a whole module... And this is where the forum lost its value.

vasilis 01-24-2020 10:36 PM

Re: 'Creating custom email notifications' dev doc
 
Quote:

It takes lots of time to go through the code though and learn what/how it does in the beginning but after a while you get used to it.
Steve, by the way, do you also do degugging step-by-step (code tracing), using an IDE with breakpoints (like for example PHPStorm), in order to find out about some code logic? I have done that a lot with XC4, but with XC5, I guess you need to do that in var/run folder.

cflsystems 01-25-2020 06:31 AM

Re: 'Creating custom email notifications' dev doc
 
You don't need to do this from the var directory. I work with the classes directory directly. And yes using IDE otherwise it will be impossible to follow the code.


All times are GMT -8. The time now is 12:35 PM.

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