Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

'Creating custom email notifications' dev doc

 
Reply
   X-Cart forums > X-Cart 5 > Dev Questions (X-Cart 5)
 
Thread Tools Search this Thread
  #1  
Old 01-22-2020, 10:40 AM
  vasilis's Avatar 
vasilis vasilis is offline
 

X-Adept
  
Join Date: Feb 2009
Posts: 758
 

Default '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?
__________________
Vasilis Vrontisis
X-Cart Development, Maintenance & Customization
https://[URL="http://www.craftforweb.com"]craftforweb.com[/url]
vasilis@craftforweb.com
Reply With Quote

The following user thanks vasilis for this useful post:
Ed B. (01-23-2020)
  #2  
Old 01-22-2020, 11:05 AM
  cflsystems's Avatar 
cflsystems cflsystems is offline
 

Veteran
  
Join Date: Apr 2007
Posts: 14,197
 

Default 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
__________________
Steve Stoyanov
CFLSystems.com
Web Development
Reply With Quote

The following user thanks cflsystems for this useful post:
vasilis (01-22-2020)
  #3  
Old 01-22-2020, 11:17 PM
  vasilis's Avatar 
vasilis vasilis is offline
 

X-Adept
  
Join Date: Feb 2009
Posts: 758
 

Default 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.
__________________
Vasilis Vrontisis
X-Cart Development, Maintenance & Customization
https://[URL="http://www.craftforweb.com"]craftforweb.com[/url]
vasilis@craftforweb.com
Reply With Quote
  #4  
Old 01-23-2020, 01:29 AM
 
webtoolsoffers webtoolsoffers is offline
    
Join Date: Jan 2020
Posts: 1
 

Default Re: 'Creating custom email notifications' dev doc

The nice one information which you have to share on this site.
__________________
shira granger
Reply With Quote
  #5  
Old 01-23-2020, 05:25 AM
  cflsystems's Avatar 
cflsystems cflsystems is offline
 

Veteran
  
Join Date: Apr 2007
Posts: 14,197
 

Default 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.
__________________
Steve Stoyanov
CFLSystems.com
Web Development
Reply With Quote

The following 2 users thank cflsystems for this useful post:
Ed B. (01-23-2020), Triple A Racing (01-23-2020)
  #6  
Old 01-23-2020, 07:05 AM
 
Triple A Racing Triple A Racing is offline
 

X-Wizard
  
Join Date: Jul 2008
Location: Manchester UK
Posts: 1,028
 

Default 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
Apparently... It's all currently being "assessed" by John Bingham. The 7th Earl of Lucan aka Lord Lucan. Don't hold your breath
__________________
Dev Store & Live Store XC Business 5.4.1.35
Server; Ubuntu 22.04.2 LTS (HWE 6.2.0.26.26 Kernel)) / Plesk Obsidian
Nginx 1.20.4 / Apache 2.4.52 (Ubuntu Backported) / MariaDB 10.11.4 / PHP 7.4.33
Reply With Quote
  #7  
Old 01-24-2020, 12:58 PM
  vasilis's Avatar 
vasilis vasilis is offline
 

X-Adept
  
Join Date: Feb 2009
Posts: 758
 

Default 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.
__________________
Vasilis Vrontisis
X-Cart Development, Maintenance & Customization
https://[URL="http://www.craftforweb.com"]craftforweb.com[/url]
vasilis@craftforweb.com
Reply With Quote
  #8  
Old 01-24-2020, 04:04 PM
  cflsystems's Avatar 
cflsystems cflsystems is offline
 

Veteran
  
Join Date: Apr 2007
Posts: 14,197
 

Default 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.
__________________
Steve Stoyanov
CFLSystems.com
Web Development
Reply With Quote
  #9  
Old 01-24-2020, 10:36 PM
  vasilis's Avatar 
vasilis vasilis is offline
 

X-Adept
  
Join Date: Feb 2009
Posts: 758
 

Default 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.
__________________
Vasilis Vrontisis
X-Cart Development, Maintenance & Customization
https://[URL="http://www.craftforweb.com"]craftforweb.com[/url]
vasilis@craftforweb.com
Reply With Quote
  #10  
Old 01-25-2020, 06:31 AM
  cflsystems's Avatar 
cflsystems cflsystems is offline
 

Veteran
  
Join Date: Apr 2007
Posts: 14,197
 

Default 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.
__________________
Steve Stoyanov
CFLSystems.com
Web Development
Reply With Quote
Reply
   X-Cart forums > X-Cart 5 > Dev Questions (X-Cart 5)



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 05:17 PM.

   

 
X-Cart forums © 2001-2020