Plugin Directory

Changeset 2691440


Ignore:
Timestamp:
03/09/2022 12:26:58 PM (4 years ago)
Author:
fastflow
Message:

Email sending fix

Location:
fast-thrivecart/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • fast-thrivecart/trunk/fast-thrivecart.php

    r2592143 r2691440  
    44 * Plugin URI: https://fastflow.io/products/fast-thrivecart
    55 * Description: ThriveCart payments Integration
    6  * Version: 1.0.3
     6 * Version: 1.0.4
    77 * Author: fastflow.io
    88 * Author URI: https://fastflow.io
  • fast-thrivecart/trunk/includes/class.thrivecart-core.php

    r2592143 r2691440  
    77    class FastThriveCart_core {
    88
    9       private $thrivecart_url;
     9      private $new_wp_user;
    1010      private $fast_thrivecart_apikey;
    1111
    1212      public function __construct(){
    13         $this->thrivecart_url = '';
     13        $this->new_wp_user = false;
    1414        $this->fast_thrivecart_apikey();
    1515        add_action('admin_notices', array($this, 'fast_thrivecart_admin_notice__error'));
     
    124124                $log_var = "<pre>" . print_r($prods_data, true) . "</pre>";
    125125                error_log("ThriveCart webhook products".$log_var);
    126                 $userid = $this->fast_thrivecart_process_user($prods_data, $raw_data_obj);
     126                $livepass = wp_generate_password();
     127                $userid = $this->fast_thrivecart_process_user($prods_data, $raw_data_obj, $livepass);
    127128                $this->fast_thrivecart_process_fm_user($userid, $prods_data, $raw_data_obj, $raw_data_obj['transactions'][$product['item_type'].'-'.$product['reference']], $product['amount_gross_str']);
     129                $this->fast_thrivecart_send_welcome_email($userid, $prods_data, $livepass);
    128130              }
    129131            }
     
    132134      }
    133135
    134       public function fast_thrivecart_process_user($prods_data, $data){
     136      public function fast_thrivecart_process_user($prods_data, $data, $generated_pass){
    135137        global $wpdb;
    136138        $chk_user = get_user_by( 'email', $data['customer']['email'] );
     
    138140            $userid = $chk_user->ID;
    139141        } else {
    140             $generated_pass = wp_generate_password();
     142            $this->new_wp_user = true;
    141143            $setpass = $generated_pass;
    142144            $username = $data['customer']['email'];
     
    259261            }
    260262          }
    261           do_action( 'FM_after_transaction_recorded', $txn_idx_id, $pid, $userid );
    262         }
    263       }
     263          do_action( 'FM_after_transaction_recorded', $txn_idx_id, $pid, $userid );
     264        }
     265      }
     266
     267      private function fast_thrivecart_send_welcome_email($userid, $prodsq, $livepass) {
     268        $subj = $prodsq->notif_welcome_subj;
     269        if (!$subj) { $subj = _fm('Login Details') .' - '.$prodsq->title; }
     270        $mailmsg = $prodsq->notif_welcome;
     271        $existpass = "[hidden]<br/>You have previously registered on the site.<br/>Please use your existing password!<br/>If you do not remember your password you can retrieve it here:<br/>" .wp_lostpassword_url()."<br/><br/>";
     272        $passphrase = $this->new_wp_user ? $livepass : $existpass;
     273        $userdata = get_userdata($userid);
     274        $subj = str_replace('[email]', $userdata->user_email, $subj);
     275        $subj = str_replace('[login]', $userdata->user_login, $subj);
     276        $subj = str_replace('[pass]', $passphrase, $subj);
     277        $subj = str_replace('[first_name]', get_user_meta($userid,'first_name', true), $subj);
     278        $subj = str_replace('[last_name]', get_user_meta($userid,'last_name', true), $subj);
     279        $subj = str_replace('[product_name]', $prodsq->title, $subj);
     280        $mailmsg = str_replace('[email]', $userdata->user_email, $mailmsg);
     281        $mailmsg = str_replace('[login]', $userdata->user_login, $mailmsg);
     282        $mailmsg = str_replace('[pass]', $passphrase, $mailmsg);
     283        $mailmsg = str_replace('[first_name]', get_user_meta($userid,'first_name', true), $mailmsg);
     284        $mailmsg = str_replace('[last_name]', get_user_meta($userid,'last_name', true), $mailmsg);
     285        $mailmsg = str_replace('[product_name]', $prodsq->title, $mailmsg);
     286        $postid = $prodsq->loginpage;
     287        if (!$postid) {
     288            global $wpdb;
     289            $postid = $wpdb->get_var("SELECT id FROM {$wpdb->prefix}posts WHERE post_content
     290            like '%[fastmemloginform product=\"$prodsq->id\"]%' AND
     291            post_status='publish' AND
     292            (post_type='page' OR post_type='post')");
     293        }
     294        if ($postid) { $url = get_permalink($postid);
     295        } else { $url = site_url('/wp-login.php'); }
     296        $mailmsg = str_replace('[loginurl]', $url, $mailmsg);
     297        if($prodsq->if_notif_welcome == 1){
     298          fastmemSendMail($userdata->user_email, $subj, $mailmsg, $prodsq->sendername, $prodsq->senderemail);
     299        }
     300    }
    264301
    265302      private function fast_thrivecart_get_membership_expiry_date($userid, $prodsq, $now) {
  • fast-thrivecart/trunk/readme.txt

    r2593143 r2691440  
    44Tags: FastFlow, Fast Member, ThriveCart, Sales Funnels, Marketing
    55Requires at least: 4.0
    6 Tested up to: 5.8
     6Tested up to: 5.9
    77Stable tag: 1.0.3
    88Requires PHP: 5.3
     
    1414== Description ==
    1515
    16 [youtube
    17 https://www.youtube.com/watch?v=PRnbY6-vnbc]
    18 
    1916Fast ThriveCart is a FastFlow add on for Fast Member. Now you can quickly and easily integrate your ThriveCart products with Fast Member and add your new customers to your WordPress membership site.
    2017
    21 Once your customers purchase through ThriveCart they are immediately added to WordPress and your chosen Fast Member products. There is support for order bumps and upsells, giving you integration across your entire sales funnel.
     18Once your customers purchase through ThriveCart they are immediately added to WordPress and your chosen Fast Member products. There is support for order bumps and upsells, giving you integration accross your entire slaes funnel.
    2219
    2320
     
    4744== Changelog ==
    4845
     46= 1.0.4 =
     47
     48Email sending fix
     49
    4950= 1.0.3 =
    5051
Note: See TracChangeset for help on using the changeset viewer.