| @@ -27,14 +27,21 @@ | ||
| 27 | 27 | */ |
| 28 | 28 | public $today_min_time; |
| 29 | 29 | |
| 30 | 30 | /** |
| 31 | + * Current query. | |
| 32 | + * | |
| 33 | + * @var boolean. | |
| 34 | + */ | |
| 35 | + public $check_current_query; | |
| 36 | + | |
| 37 | + /** | |
| 31 | 38 | * Data_Updater constructor. |
| 32 | 39 | * |
| 33 | 40 | * @since 1.1.0 |
| 34 | 41 | */ |
| 35 | 42 | public function __construct() { |
| 36 | - $this->today_min_time = strtotime( date( 'Y-m-d 0:0:0' ) ); | |
| 43 | + $this->today_min_time = strtotime( gmdate( 'Y-m-d 0:0:0' ) ); | |
| 37 | 44 | } |
| 38 | 45 | |
| 39 | 46 | /** |
| 40 | 47 | * Sets funnel id. |
| @@ -205,7 +212,35 @@ | ||
| 205 | 212 | $wpdb->prepare( "UPDATE `$table` SET upsell_revenue = %s WHERE funnel_id = %d AND applied_at > %s", $data[ 'upsell_revenue' ] + $order->get_total(), $this->funnel_id, $this->today_min_time ) |
| 206 | 213 | ); |
| 207 | 214 | } |
| 208 | 215 | |
| 216 | + //phpcs:enable | |
| 217 | + } | |
| 218 | + | |
| 219 | + /** | |
| 220 | + * Adds new order log for accepted upsell. | |
| 221 | + * | |
| 222 | + * @since 1.9.2 | |
| 223 | + * @param double|int $total Upsell total price. | |
| 224 | + */ | |
| 225 | + public function add_new_upsell_revenue_log( $total ) { | |
| 226 | + $data = self::has_funnel_data(); | |
| 227 | + | |
| 228 | + if ( empty( $data ) ) { | |
| 229 | + return; | |
| 230 | + } | |
| 231 | + | |
| 232 | + global $wpdb; | |
| 233 | + | |
| 234 | + $table = $wpdb->prefix . Database::DATABASE_PREFIX . 'applied_funnel'; | |
| 235 | + | |
| 236 | + if ( empty( $data['revenue'] ) ) { | |
| 237 | + $data['revenue'] = 0; | |
| 238 | + } | |
| 239 | + | |
| 240 | + //phpcs:disable | |
| 241 | + $wpdb->query( | |
| 242 | + $wpdb->prepare( "UPDATE `$table` SET upsell_revenue = %s WHERE funnel_id = %d AND applied_at > %s", $data[ 'upsell_revenue' ] + $total, $this->funnel_id, $this->today_min_time ) | |
| 243 | + ); | |
| 209 | 244 | //phpcs:enable |
| 210 | 245 | } |
| 211 | 246 | } |