Page 1 of 3 123 LastLast
Results 1 to 10 of 25
  1. #1
    Join Date
    May 2006
    Location
    Gardiner, Maine
    Posts
    2,296
    Plugin Contributions
    22

    Default JSON & TrustPilot

    TrustPilot is a reviews site that requires, either 1) a BCC email of the sale or 2) JSON coding of a similar email.

    I have no idea why you can't just add the additional email address in admin but they claim it has to be a BCC, not a separate email copy.

    Looking into this I know that what should be done is to use an observer to trigger the addition of a BCC line when an order is placed. That's just not something I've ever stepped into.

    This post steps into it but it dates from 2008.##https://www.zen-cart.com/showthread....il-to-Customer

    So if what they are saying is true and all we need is an additional BCC added to the email, this actually sounds pretty simple if one knows how to do it. So the question becomes, is it as simple as it now appears?##

    If it is, perhaps someone can direct me to examples of this type of thing in perhaps a plugin or give me some solid hints as to how to alter this provided code from 2008:
    PHP Code:
    class sendBCCofAdminEmails extends base {

     
    /**  constructor method !
       *
       * Attach observer class to the global $zco_notifier and watch for a single notifier event.
       */
      
    function sendBCCofAdminEmails() {
        
    $this->attach($this, array('NOTIFY_EMAIL_BEFORE_PROCESS_ATTACHMENTS'));
      }


     
    /**   Actual Method that does the desired activity
       *
       * Called by observed class when any of the notifiable events occur
       *
       * @param object $class
       * @param string $eventID
       */
      
    function update(&$class$eventID$paramsArray = array()) {
        global 
    $mail$module;
        if (
    $paramsArray['module'] == 'direct_email'$mail->AddBCC(STORE_NAMESTORE_OWNER_EMAIL_ADDRESS);
      }

    That is adding a bcc if one is sending email through the admin. So what would the triggering code be to add to an order? Or am I off track here?
    The full-time Zen Cart Guru. WizTech4ZC.com

  2. #2
    Join Date
    Nov 2005
    Location
    los angeles
    Posts
    2,688
    Plugin Contributions
    9

    Default Re: JSON & TrustPilot

    delia,
    i will go on the assumption that you can get your observer to load. in v157, the auto loading observer function is pretty cool; but you are running v156 which means no auto loading of your observer.

    just in case, here is the link on getting the observer to load:

    https://docs.zen-cart.com/dev/code/n...observer-class

    after that, this is how i would code it.

    PHP Code:
    <?php

        
    class sendBCCofAdminEmails extends base
        
    {
            public function 
    __construct()
            {
                
    $this->attach($this, [
                    
    'NOTIFY_EMAIL_BEFORE_PROCESS_ATTACHMENTS',
                ]);
            }

            public function 
    update(&$class$eventID, &$p1, &$p2, &$p3, &$p4, &$p5, &$p6, &$p7, &$p8)
            {
                switch (
    $eventID) {
                    case 
    'NOTIFY_EMAIL_BEFORE_PROCESS_ATTACHMENTS':
                        if ((
    strpos($p2->subject'Order Confirmation') !== false) && (strpos($p2->subject'NEW ORDER') === false)) {
                            
    $p2->addBCC('trustpilot at whatever.com');
                        }
                        break;
                }
            }
        }
    obviously one can change the conditional as necessary. but i'm pretty confident this works.

    hope that helps!
    author of square Webpay.
    mxWorks has premium plugins. donations: venmo or paypal accepted.
    premium consistent excellent support. available for hire.

  3. #3
    Join Date
    May 2006
    Location
    Gardiner, Maine
    Posts
    2,296
    Plugin Contributions
    22

    Default Re: JSON & TrustPilot

    oh man, that's perfect. But the site is 1.5.6. Is there much difference between the two in this case?
    The full-time Zen Cart Guru. WizTech4ZC.com

  4. #4
    Join Date
    Nov 2005
    Location
    los angeles
    Posts
    2,688
    Plugin Contributions
    9

    Default Re: JSON & TrustPilot

    create a file named as such:

    includes/auto_loaders/config.delia_mods.php

    in that file, put:

    PHP Code:
    <?php
        $autoLoadConfig
    [202][] = [
            
    'autoType' => 'class',
            
    'loadFile' => 'observers/sendBCCofAdminEmails.php',
            
    'classPath' => DIR_WS_CLASSES
        
    ];

             
    $autoLoadConfig[202][] = [
            
    'autoType' => 'classInstantiate',
            
    'className' => 'sendBCCofAdminEmails',
            
    'objectName' => 'sendBCCofAdminEmails'
        
    ];
    make sure the previous code is here:

    includes/classes/observers/sendBCCofAdminEmails.php

    getting stuff to load can be tricky.

    best.
    author of square Webpay.
    mxWorks has premium plugins. donations: venmo or paypal accepted.
    premium consistent excellent support. available for hire.

  5. #5
    Join Date
    May 2006
    Location
    Gardiner, Maine
    Posts
    2,296
    Plugin Contributions
    22

    Default Re: JSON & TrustPilot

    thank you so much!!
    The full-time Zen Cart Guru. WizTech4ZC.com

  6. #6
    Join Date
    Nov 2005
    Location
    los angeles
    Posts
    2,688
    Plugin Contributions
    9

    Default Re: JSON & TrustPilot

    Quote Originally Posted by delia View Post
    thank you so much!!
    author of square Webpay.
    mxWorks has premium plugins. donations: venmo or paypal accepted.
    premium consistent excellent support. available for hire.

  7. #7
    Join Date
    May 2006
    Location
    Gardiner, Maine
    Posts
    2,296
    Plugin Contributions
    22

    Default Re: JSON & TrustPilot

    after creating numerous errors, the site is back to working. But no extra bbc email was sent/received. Since there was no errors was the class actually loaded? I assumed so but then realized I actually don't know. Definitely didn't work.
    The full-time Zen Cart Guru. WizTech4ZC.com

  8. #8
    Join Date
    Nov 2005
    Location
    los angeles
    Posts
    2,688
    Plugin Contributions
    9

    Default Re: JSON & TrustPilot

    Quote Originally Posted by delia View Post
    after creating numerous errors, the site is back to working. But no extra bbc email was sent/received. Since there was no errors was the class actually loaded? I assumed so but then realized I actually don't know. Definitely didn't work.
    yeah, as i stated the loading can be tricky.

    i have added a couple of trigger_error statements which should result in debug logs getting generated. we may be getting the observer loaded, but then may not make it inside the conditional if the following is overridden (or if the language is not english):

    includes/languages/english/checkout_process.php:9: define('EMAIL_TEXT_SUBJECT', 'Order Confirmation');

    the bcc will only work for an order confirmation to the customer.

    so try adding the trigger_error statements and see if any debug logs get generated:

    PHP Code:
    <?php

        
    class sendBCCofAdminEmails extends base
        
    {
            public function 
    __construct()
            {
                
    $this->attach($this, [
                    
    'NOTIFY_EMAIL_BEFORE_PROCESS_ATTACHMENTS',
                ]);
            }

            public function 
    update(&$class$eventID, &$p1, &$p2, &$p3, &$p4, &$p5, &$p6, &$p7, &$p8)
            {
                switch (
    $eventID) {
                    case 
    'NOTIFY_EMAIL_BEFORE_PROCESS_ATTACHMENTS':
                        
    trigger_error('the observer got loaded!');
                        if ((
    strpos($p2->subject'Order Confirmation') !== false) && (strpos($p2->subject'NEW ORDER') === false)) {
                            
    trigger_error('we are inside the conditional!');
                            
    $p2->addBCC('trustpilot at whatever.com');
                        }
                        break;
                }
            }
        }
    best.
    author of square Webpay.
    mxWorks has premium plugins. donations: venmo or paypal accepted.
    premium consistent excellent support. available for hire.

  9. #9
    Join Date
    May 2006
    Location
    Gardiner, Maine
    Posts
    2,296
    Plugin Contributions
    22

    Default Re: JSON & TrustPilot

    and it says the class got loaded so that question is answered. But still no email.

    Now to add in to that, this site will not send copy of order emails to multiple recipients, only to the first one. I saw an old post where DrByte says that's an indication of some sort of corruption? As this is a clean install on an old database, that can't be though so many things have gone wrong with site that I felt obligation to do a clean install and rebuild. I wouldn't think that would create this present problem but just in case, throwing it out there.
    The full-time Zen Cart Guru. WizTech4ZC.com

  10. #10
    Join Date
    Nov 2005
    Location
    los angeles
    Posts
    2,688
    Plugin Contributions
    9

    Default Re: JSON & TrustPilot

    what about this?

    trigger_error('we are inside the conditional!');

    does it say we are inside the conditional?

    you can now change the first trigger error to this:

    trigger_error('Subject: ' . $p2->subject);

    if the class is loaded, then we need to get inside the conditional.

    the database and the rest of that stuff have nothing to do with existing troubleshooting. either we get inside the conditional or not. if we get in and no bcc gets generated we then need to look at mail function.

    best.
    author of square Webpay.
    mxWorks has premium plugins. donations: venmo or paypal accepted.
    premium consistent excellent support. available for hire.

 

 
Page 1 of 3 123 LastLast

Similar Threads

  1. v155 Did myISP upgraded my VPS and forgot to install json?
    By chibipaw in forum General Questions
    Replies: 2
    Last Post: 6 Jan 2020, 05:07 PM
  2. Unexpected token m in JSON at position 0
    By larrynhien in forum Templates, Stylesheets, Page Layout
    Replies: 8
    Last Post: 14 Sep 2016, 02:06 AM
  3. v155 JSON syntax error on shopping cart page
    By sports guy in forum General Questions
    Replies: 7
    Last Post: 9 Sep 2016, 10:17 PM
  4. json error with zc 1.5 eventhough json installed
    By bangsters in forum General Questions
    Replies: 4
    Last Post: 29 Feb 2012, 08:28 PM
  5. JSON undefined in internet explorer 6 and 7
    By lindanewbie in forum General Questions
    Replies: 1
    Last Post: 10 Mar 2011, 11:27 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR