| 1 |
<?php |
| 2 |
/** |
| 3 |
* Sticky add-to-cart Functions Class. |
| 4 |
* |
| 5 |
* @package Rse\SB |
| 6 |
*/ |
| 7 |
|
| 8 |
namespace RadiusTheme\SB\Modules\AbandonedCartRecovery; |
| 9 |
|
| 10 |
use RadiusTheme\SB\Helpers\Fns; |
| 11 |
|
| 12 |
defined( 'ABSPATH' ) || exit(); |
| 13 |
|
| 14 |
/** |
| 15 |
* Sticky add-to-cart Functions Class. |
| 16 |
*/ |
| 17 |
class CartRecoveryOptions { |
| 18 |
/** |
| 19 |
* @return array[] |
| 20 |
*/ |
| 21 |
private static function get_default_templates() { |
| 22 |
ob_start(); |
| 23 |
?> |
| 24 |
<p> Few days back you left {{cart.product.names}} in your cart.</p> |
| 25 |
<p>To help make up your mind, we have added an exclusive 10% discount coupon {{cart.coupon_code}} to your cart.</p> |
| 26 |
<p><a href="{{cart.checkout_url}}" target="_blank" rel="noopener">Complete Your Purchase Now >></a></p> |
| 27 |
<p>Hurry! This is a onetime offer and will expire in 24 Hours.</p> |
| 28 |
<p>In case you couldn't finish your order due to technical difficulties or because you need some help, just reply to this email we will be happy to help.</p> |
| 29 |
<p>Kind Regards,<br />{{admin.firstname}}<br />{{admin.company}}</p> |
| 30 |
<p>{{cart.unsubscribe}}</p> |
| 31 |
<?php |
| 32 |
$first_email = esc_attr( ob_get_clean() ); |
| 33 |
ob_start(); |
| 34 |
?> |
| 35 |
<p>Hi {{customer.firstname}}!</p> |
| 36 |
<p>I'm {{admin.firstname}}, and I help handle customer issues at {{admin.company}}.</p> |
| 37 |
<p>I just noticed that you tried to make a purchase, but unfortunately, there was some trouble. Is there anything I can do to help?</p> |
| 38 |
<p>You should be able to complete your checkout in less than a minute:<br /><a href="{{cart.checkout_url}}" target="_blank" rel="noopener"> Click here to continue your purchase </a></p> |
| 39 |
<p>Thanks!<br />{{admin.firstname}}<br />{{admin.company}}</p> |
| 40 |
<p>{{cart.unsubscribe}}</p> |
| 41 |
<?php |
| 42 |
$second_email = esc_attr( ob_get_clean() ); |
| 43 |
ob_start(); |
| 44 |
?> |
| 45 |
<p>Hi {{customer.firstname}}!</p> |
| 46 |
<p>I'm {{admin.firstname}}, and I help handle customer issues at {{admin.company}}.</p> |
| 47 |
<p>I just noticed that you tried to make a purchase, but unfortunately, there was some trouble. Is there anything I can do to help?</p> |
| 48 |
<p>You should be able to complete your checkout in less than a minute:<br /><a href="{{cart.checkout_url}}" target="_blank" rel="noopener"> Click here to continue your purchase </a></p> |
| 49 |
<p>Thanks!<br />{{admin.firstname}}<br />{{admin.company}}</p> |
| 50 |
<p>{{cart.unsubscribe}}</p> |
| 51 |
<?php |
| 52 |
$third_email = esc_attr( ob_get_clean() ); |
| 53 |
return [ |
| 54 |
[ |
| 55 |
'template_status' => 'on', |
| 56 |
'title' => 'First Email', |
| 57 |
'subject' => 'First Email', |
| 58 |
'email_frequency_unit' => 'days', |
| 59 |
'email_frequency' => 1, |
| 60 |
'content' => $first_email, |
| 61 |
], |
| 62 |
[ |
| 63 |
'template_status' => 'on', |
| 64 |
'title' => 'Second Email', |
| 65 |
'subject' => 'Second Email', |
| 66 |
'email_frequency_unit' => 'days', |
| 67 |
'email_frequency' => 1, |
| 68 |
'content' => $second_email, |
| 69 |
], |
| 70 |
[ |
| 71 |
'template_status' => 'on', |
| 72 |
'title' => 'Third Email', |
| 73 |
'subject' => 'Third Email', |
| 74 |
'email_frequency_unit' => 'days', |
| 75 |
'email_frequency' => 1, |
| 76 |
'content' => $third_email, |
| 77 |
], |
| 78 |
]; |
| 79 |
} |
| 80 |
/** |
| 81 |
* @return mixed|null |
| 82 |
*/ |
| 83 |
public static function get_cart_recovery_fields() { |
| 84 |
return apply_filters( |
| 85 |
'rtsb/module/abandoned_cart_recovery/fields', |
| 86 |
[ |
| 87 |
'abandoned_time' => [ |
| 88 |
'id' => 'abandoned_time', |
| 89 |
'type' => 'slider', |
| 90 |
'min' => 2, |
| 91 |
'max' => 60, |
| 92 |
'value' => 20, |
| 93 |
'unit' => 'minutes', |
| 94 |
'label' => esc_html__( 'Time to Mark Cart Abandoned ( minutes ) ', 'shopbuilder' ), |
| 95 |
'help' => esc_html__( 'When enabled, the plugin will track cart activity and mark carts as abandoned after the defined cut-off time (in minutes).', 'shopbuilder' ), |
| 96 |
'tab' => 'general', |
| 97 |
], |
| 98 |
'disable_tracking_roles' => [ |
| 99 |
'id' => 'disable_tracking_roles', |
| 100 |
'label' => esc_html__( 'Exclude User Roles from Tracking', 'shopbuilder' ), |
| 101 |
'help' => esc_html__( 'Carts belonging to users with these roles will not be tracked for abandonment. These users will not receive abandoned cart reminder emails.', 'shopbuilder' ), |
| 102 |
'type' => 'checkbox', |
| 103 |
'value' => [ 'editor', 'author' ], |
| 104 |
'options' => array_map( |
| 105 |
function ( $status_key, $status_label ) { |
| 106 |
return [ |
| 107 |
'value' => $status_key, |
| 108 |
'label' => $status_label, |
| 109 |
]; |
| 110 |
}, |
| 111 |
array_keys( Fns::get_all_user_roles() ), |
| 112 |
Fns::get_all_user_roles() |
| 113 |
) , |
| 114 |
'multiple' => true, |
| 115 |
'tab' => 'general', |
| 116 |
], |
| 117 |
'notify_recovery_to_admin' => [ |
| 118 |
'id' => 'notify_recovery_to_admin', |
| 119 |
'type' => 'switch', |
| 120 |
'default' => true, |
| 121 |
'label' => esc_html__( 'Notify Recovery To Admin', 'shopbuilder' ), |
| 122 |
'help' => esc_html__( 'Enable this option to send a notification to the site administrator whenever a cart is successfully recovered.', 'shopbuilder' ), |
| 123 |
'tab' => 'general', |
| 124 |
], |
| 125 |
'recovery_notify_title' => [ |
| 126 |
'id' => 'recovery_notify_title', |
| 127 |
'type' => 'text', |
| 128 |
'label' => esc_html__( 'Recovery Email Subject', 'shopbuilder' ), |
| 129 |
'help' => esc_html__( 'Enter the subject line for recovery notification emails sent to admin.', 'shopbuilder' ), |
| 130 |
'placeholder' => esc_html__( 'Cart Recovered', 'shopbuilder' ), |
| 131 |
'value' => esc_html__( 'Cart Recovered', 'shopbuilder' ), |
| 132 |
'tab' => 'general', |
| 133 |
'dependency' => [ |
| 134 |
'rules' => [ |
| 135 |
[ |
| 136 |
'item' => 'modules.abandoned_cart_recovery.notify_recovery_to_admin', |
| 137 |
'value' => 'on', |
| 138 |
'operator' => '==', |
| 139 |
], |
| 140 |
], |
| 141 |
], |
| 142 |
], |
| 143 |
'recovery_admin_email' => [ |
| 144 |
'id' => 'recovery_admin_email', |
| 145 |
'type' => 'textarea', |
| 146 |
'label' => esc_html__( 'Admin Email Address', 'shopbuilder' ), |
| 147 |
'help' => esc_html__( 'Enter email addresses separated by commas to receive recovery report emails. Ex: support@yourstore.com, thesupport2@yourstore.com ', 'shopbuilder' ), |
| 148 |
'placeholder' => 'example@yourstore.com, example2@yourstore.com', |
| 149 |
'tab' => 'general', |
| 150 |
'dependency' => [ |
| 151 |
'rules' => [ |
| 152 |
[ |
| 153 |
'item' => 'modules.abandoned_cart_recovery.notify_recovery_to_admin', |
| 154 |
'value' => 'on', |
| 155 |
'operator' => '==', |
| 156 |
], |
| 157 |
], |
| 158 |
], |
| 159 |
], |
| 160 |
'unsubscribe_page' => [ |
| 161 |
'id' => 'unsubscribe_page', |
| 162 |
'type' => 'select', |
| 163 |
'label' => esc_html__( 'Unsubscribe Page', 'shopbuilder' ), |
| 164 |
'help' => esc_html__( 'Choose the page where users will be redirected to unsubscribe.', 'shopbuilder' ), |
| 165 |
'options' => Fns::get_pages(), |
| 166 |
'tab' => 'general', |
| 167 |
], |
| 168 |
// Send Recovery Report Emails. |
| 169 |
'email_settings' => [ |
| 170 |
'id' => 'email_settings', |
| 171 |
'type' => 'title', |
| 172 |
'label' => esc_html__( 'Email', 'shopbuilder' ), |
| 173 |
'tab' => 'general', |
| 174 |
], |
| 175 |
// "From" Name |
| 176 |
'from_name' => [ |
| 177 |
'id' => 'from_name', |
| 178 |
'label' => esc_html__( '"From" Name', 'shopbuilder' ), |
| 179 |
'help' => esc_html__( 'The name that will appear as the sender in the email.', 'shopbuilder' ), |
| 180 |
'type' => 'text', |
| 181 |
'placeholder' => esc_html__( 'John Doe', 'shopbuilder' ), |
| 182 |
'tab' => 'general', |
| 183 |
], |
| 184 |
'from_address' => [ |
| 185 |
'id' => 'from_address', |
| 186 |
'label' => esc_html__( '"From" Email Address', 'shopbuilder' ), |
| 187 |
'help' => esc_html__( 'The email address from which recovery emails will be sent.', 'shopbuilder' ), |
| 188 |
'type' => 'email', |
| 189 |
'placeholder' => esc_html__( 'example@yourstore.com', 'shopbuilder' ), |
| 190 |
'tab' => 'general', |
| 191 |
], |
| 192 |
'reply_to_address' => [ |
| 193 |
'id' => 'reply_to_address', |
| 194 |
'label' => esc_html__( '"Reply-To" Email Address', 'shopbuilder' ), |
| 195 |
'help' => esc_html__( 'The email address where replies from customers should be sent.', 'shopbuilder' ), |
| 196 |
'type' => 'email', |
| 197 |
'placeholder' => esc_html__( 'support@yourstore.com', 'shopbuilder' ), |
| 198 |
'tab' => 'general', |
| 199 |
], |
| 200 |
'coupon_settings' => [ |
| 201 |
'id' => 'coupon_settings', |
| 202 |
'type' => 'title', |
| 203 |
'label' => esc_html__( 'Coupon Settings', 'shopbuilder' ), |
| 204 |
'tab' => 'general', |
| 205 |
], |
| 206 |
'delete_coupons_automatically' => [ |
| 207 |
'id' => 'delete_coupons_automatically', |
| 208 |
'type' => 'switch', |
| 209 |
'default' => true, |
| 210 |
'label' => esc_html__( 'Auto-Delete Expired Coupons', 'shopbuilder' ), |
| 211 |
'help' => esc_html__( 'Enable this to automatically remove expired or used coupons once per week via a scheduled task.', 'shopbuilder' ), |
| 212 |
'tab' => 'general', |
| 213 |
], |
| 214 |
'email_template' => [ |
| 215 |
'id' => 'email_template', |
| 216 |
'type' => 'cart_recovery_email_template', |
| 217 |
'label' => esc_html__( 'Abandoned Cart Email Templates', 'shopbuilder' ), |
| 218 |
'tab' => 'emailTemplates', |
| 219 |
'defaults' => self::get_default_templates(), |
| 220 |
], |
| 221 |
|
| 222 |
] |
| 223 |
); |
| 224 |
} |
| 225 |
} |
| 226 |
|