/** * Test variable and variations. * * @since 2.7.0 */ function test_variables_and_variations() { $product = new WC_Product_Variable(); $product->set_name('Variable Product'); $attribute = new WC_Product_Attribute(); $attribute->set_id(0); $attribute->set_name('pa_color'); $attribute->set_options(explode(WC_DELIMITER, 'green | red')); $attribute->set_visible(false); $attribute->set_variation(true); $product->set_attributes(array($attribute)); $product->save(); $this->assertEquals('Variable Product', $product->get_name()); $variation = new WC_Product_Variation(); $variation->set_name('Variation #1 of Dummy Variable CRUD Product'); $variation->set_parent_id($product->get_id()); $variation->set_regular_price(10); $variation->set_sku('CRUD DUMMY SKU VARIABLE GREEN'); $variation->set_manage_stock('no'); $variation->set_downloadable('no'); $variation->set_virtual('no'); $variation->set_stock_status('instock'); $variation->set_attributes(array('pa_color' => 'green')); $variation->save(); $this->assertEquals('Variation #1 of Dummy Variable CRUD Product', $variation->get_name()); $this->assertEquals('CRUD DUMMY SKU VARIABLE GREEN', $variation->get_sku()); $this->assertEquals(10, $variation->get_price()); $product = new WC_Product_Variable($product->get_id()); $children = $product->get_children(); $this->assertEquals($variation->get_id(), $children[0]); $expected_attributes = array('pa_color' => array('green')); $this->assertEquals($expected_attributes, $product->get_variation_attributes()); $variation_2 = new WC_Product_Variation(); $variation_2->set_name('Variation #2 of Dummy Variable CRUD Product'); $variation_2->set_parent_id($product->get_id()); $variation_2->set_regular_price(10); $variation_2->set_sku('CRUD DUMMY SKU VARIABLE RED'); $variation_2->set_manage_stock('no'); $variation_2->set_downloadable('no'); $variation_2->set_virtual('no'); $variation_2->set_stock_status('instock'); $variation_2->set_attributes(array('pa_color' => 'red')); $variation_2->save(); $this->assertEquals('Variation #2 of Dummy Variable CRUD Product', $variation_2->get_name()); $this->assertEquals('CRUD DUMMY SKU VARIABLE RED', $variation_2->get_sku()); $this->assertEquals(10, $variation_2->get_price()); $product = new WC_Product_Variable($product->get_id()); $children = $product->get_children(); $this->assertEquals($variation_2->get_id(), $children[1]); $this->assertEquals(2, count($children)); $expected_attributes = array('pa_color' => array('green', 'red')); $this->assertEquals($expected_attributes, $product->get_variation_attributes()); $variation_2->set_name('UPDATED - Variation #2 of Dummy Variable CRUD Product'); $variation_2->set_regular_price(15); $variation_2->set_sale_price(9.99); $variation_2->set_date_on_sale_to('32532537600'); $variation_2->save(); $product = new WC_Product_Variable($product->get_id()); $expected_prices['price'][$children[0]] = 10.0; $expected_prices['price'][$children[1]] = 9.99; $expected_prices['regular_price'][$children[0]] = 10.0; $expected_prices['regular_price'][$children[1]] = 15.0; $expected_prices['sale_price'][$children[0]] = 10.0; $expected_prices['sale_price'][$children[1]] = 9.99; $this->assertEquals($expected_prices, $product->get_variation_prices()); $this->assertEquals('UPDATED - Variation #2 of Dummy Variable CRUD Product', $variation_2->get_name()); $product->set_name('Renamed Variable Product'); $product->save(); $this->assertEquals('Renamed Variable Product', $product->get_name()); $product->delete(); }
function display_price_in_variation_option_name($term) { global $wpdb, $product; $term_temp = $term; $term = strtolower($term); $term = str_replace(' ', '-', $term); $result = $wpdb->get_col("SELECT slug FROM {$wpdb->prefix}terms WHERE name = '{$term}'"); $term_slug = !empty($result) ? $result[0] : $term; $query = "SELECT postmeta.post_id AS product_id\nFROM {$wpdb->prefix}postmeta AS postmeta\nLEFT JOIN {$wpdb->prefix}posts AS products ON ( products.ID = postmeta.post_id )\nWHERE postmeta.meta_key LIKE 'attribute_%'\nAND postmeta.meta_value = '{$term_slug}'\nAND products.post_parent = {$product->id}"; $variation_id = $wpdb->get_col($query); $parent = wp_get_post_parent_id($variation_id[0]); if ($parent > 0) { $_product = new WC_Product_Variation($variation_id[0]); $testVariable = $_product->get_variation_attributes(); $itemPrice = strip_tags(woocommerce_price($_product->get_price())); $getPrice = $_product->get_price(); $itemPriceInt = (int) $getPrice; $term = $term_temp; //this is where you can actually customize how the price is displayed if ($itemPriceInt > 0) { return $term . ' (' . $itemPrice . ' incl. GST)'; } else { return $term . ' (' . $itemPrice . ')'; } } return $term; }
function display_price_in_variation_option_name($term) { global $wpdb, $product; $result = $wpdb->get_col("SELECT slug FROM {$wpdb->prefix}terms WHERE name = '{$term}'"); $term_slug = !empty($result) ? $result[0] : $term; $query = "SELECT postmeta.post_id AS product_id\n\t\t\tFROM {$wpdb->prefix}postmeta AS postmeta\n\t\t\tLEFT JOIN {$wpdb->prefix}posts AS products ON ( products.ID = postmeta.post_id )\n\t\t\tWHERE postmeta.meta_key LIKE 'attribute_%'\n\t\t\tAND postmeta.meta_value = '{$term_slug}'\n\t\t\tAND products.post_parent = {$product->id}"; $variation_id = $wpdb->get_col($query); $parent = wp_get_post_parent_id($variation_id[0]); if ($parent > 0) { $_product = new WC_Product_Variation($variation_id[0]); //this is where you can actually customize how the price is displayed return wp_strip_all_tags($term . ' (' . woocommerce_price($_product->get_price()) . ')', true); } return wp_strip_all_tags($term, true); }
/** * Maybe display pricing table or anchor to display pricing table in modal * * @access public * @return void */ public function product_page_pricing_table() { if ($this->opt['settings']['display_table'] == 'hide' && (!isset($this->opt['settings']['display_offers']) || $this->opt['settings']['display_offers'] == 'hide')) { return; } global $product; if (!$product) { return; } // Load required classes require_once RP_WCDPD_PLUGIN_PATH . 'includes/classes/Pricing.php'; $selected_rule = null; // Iterate over pricing rules and use the first one that has this product in conditions (or does not have if condition "not in list") if (isset($this->opt['pricing']['sets']) && count($this->opt['pricing']['sets'])) { foreach ($this->opt['pricing']['sets'] as $rule_key => $rule) { if ($rule['method'] == 'quantity' && ($validated_rule = RP_WCDPD_Pricing::validate_rule($rule))) { if ($validated_rule['selection_method'] == 'all' && $this->user_matches_rule($validated_rule)) { $selected_rule = $validated_rule; break; } if ($validated_rule['selection_method'] == 'categories_include' && count(array_intersect($this->get_product_categories($product->id), $validated_rule['categories'])) > 0 && $this->user_matches_rule($validated_rule)) { $selected_rule = $validated_rule; break; } if ($validated_rule['selection_method'] == 'categories_exclude' && count(array_intersect($this->get_product_categories($product->id), $validated_rule['categories'])) == 0 && $this->user_matches_rule($validated_rule)) { $selected_rule = $validated_rule; break; } if ($validated_rule['selection_method'] == 'products_include' && in_array($product->id, $validated_rule['products']) && $this->user_matches_rule($validated_rule)) { $selected_rule = $validated_rule; break; } if ($validated_rule['selection_method'] == 'products_exclude' && !in_array($product->id, $validated_rule['products']) && $this->user_matches_rule($validated_rule)) { $selected_rule = $validated_rule; break; } } } } if (is_array($selected_rule)) { // Quantity if ($selected_rule['method'] == 'quantity' && in_array($this->opt['settings']['display_table'], array('modal', 'inline')) && isset($selected_rule['pricing'])) { if ($product->product_type == 'variable') { $product_variations = $product->get_available_variations(); } // For variable products only - check if prices differ for different variations $multiprice_variable_product = false; if ($product->product_type == 'variable' && !empty($product_variations)) { $last_product_variation = array_slice($product_variations, -1); $last_product_variation_object = new WC_Product_Variable($last_product_variation[0]['variation_id']); $last_product_variation_price = $last_product_variation_object->get_price(); foreach ($product_variations as $variation) { $variation_object = new WC_Product_Variable($variation['variation_id']); if ($variation_object->get_price() != $last_product_variation_price) { $multiprice_variable_product = true; } } } if ($multiprice_variable_product) { $variation_table_data = array(); foreach ($product_variations as $variation) { $variation_product = new WC_Product_Variation($variation['variation_id']); $variation_table_data[$variation['variation_id']] = $this->pricing_table_calculate_adjusted_prices($selected_rule['pricing'], $variation_product->get_price()); } require_once RP_WCDPD_PLUGIN_PATH . 'includes/views/frontend/table-variable.php'; } else { if ($product->product_type == 'variable' && !empty($product_variations)) { $variation_product = new WC_Product_Variation($last_product_variation[0]['variation_id']); $table_data = $this->pricing_table_calculate_adjusted_prices($selected_rule['pricing'], $variation_product->get_price()); } else { $table_data = $this->pricing_table_calculate_adjusted_prices($selected_rule['pricing'], $product->get_price()); } require_once RP_WCDPD_PLUGIN_PATH . 'includes/views/frontend/table-' . $this->opt['settings']['display_table'] . '-' . $this->opt['settings']['pricing_table_style'] . '.php'; } } } }
*/ if (!defined('ABSPATH')) { exit; // Exit if accessed directly } global $post, $product; $sale_percent = 0; if ($product->is_on_sale() && $product->product_type != 'grouped') { if ($product->product_type == 'variable') { $available_variations = $product->get_available_variations(); for ($i = 0; $i < count($available_variations); ++$i) { $variation_id = $available_variations[$i]['variation_id']; $variable_product1 = new WC_Product_Variation($variation_id); $regular_price = $variable_product1->get_regular_price(); $sales_price = $variable_product1->get_sale_price(); $price = $variable_product1->get_price(); if ($sales_price != $regular_price && $sales_price == $price) { $percentage = round(($regular_price - $sales_price) / $regular_price * 100, 1); if ($percentage > $sale_percent) { $sale_percent = $percentage; } } } } else { $sale_percent = round(($product->get_regular_price() - $product->get_sale_price()) / $product->get_regular_price() * 100, 1); } } ?> <?php if ($sale_percent > 0) {
$upgradeVariation = 783; break; case 100: $upgradeamount = 200; $upgradeVariation = 784; break; case 200: $upgradeamount = -1; // Need to handle the top item with contact us. $upgradeVariation = -1; // Need to handle unknown cost... break; } } $_product = new WC_Product_Variation($upgradeVariation); $upgradecost = intval($_product->get_price()) - $totalPrice + $addupgrade_cost; } } //Setting the counts if ($upgradeamount >= 0) { $the_final_count = strtoupper($upgradeamount); } } ?> <?php if (false) { // Old layout for counter ?> <em class="counter"><?php echo $received_count; ?>
$product_id = mysql_real_escape_string($_POST['productid']); if ($product_id == 'undefined') { $product_id = ''; } if (!empty($product_id)) { $product = new WC_Product($product_id); $productPrice = $product->get_price(); } // Get the variant of the product if set $variation_id = mysql_real_escape_string($_POST['variationid']); if ($variation_id == 'undefined') { $variation_id = ''; } if (!empty($variation_id)) { $variation = new WC_Product_Variation($variation_id); $productPrice = $variation->get_price(); } // If user has required ammount of credits then continue if ($getUserCredit >= $productPrice) { get_currentuserinfo(); // Save the purchase to the database and update credits balance of the user $sql = $wpdb->query("UPDATE `" . $wpdb->prefix . "woocredit_users` SET credit = '" . ($getUserCredit - $productPrice) . "' where user_id=" . get_current_user_id()); $sql = $wpdb->query("INSERT INTO `" . $wpdb->prefix . "woocredit_products` (user_id, product_id, price) VALUES (" . get_current_user_id() . "," . $_POST['productid'] . "," . $productPrice . ")"); // If the product or variant are downloadable then send an email with a link to the files if ($product && $product->is_downloadable() || $variation && $variation->is_downloadable()) { $files = []; if ($product && $product->is_downloadable()) { $files = $product->get_files(); } if ($variation && $variation->is_downloadable()) { $files = $variation->get_files();
/** * This function shows the buy for credit button on products page * @param int $attr */ function single_product_buy_button($attr) { global $translate; global $product; $class = ''; extract(shortcode_atts(array('class' => 'class', 'title' => 'title'), $attr)); if ($class !== 'class') { $class = 'class="' . $class . '"'; } else { $class = 'class="creditsBuyButton button"'; } if ($product->product_type == 'variable') { $available_variations = $product->get_available_variations(); if (!empty($available_variations)) { foreach ($available_variations as $variation) { $variation = new WC_Product_Variation($variation['variation_id']); $title = $variation->get_price() . ' ' . $translate->wooTranslate('Credits', get_bloginfo('language')) . ' - ' . implode(', ', $variation->get_variation_attributes()); echo '<a ' . $class . ' href="javascript:void(0);" onclick="creditdeduct(' . $product->id . ',' . $variation->get_price() . ',' . $variation->variation_id . ')" >' . $title . '</a><br/>'; } } } else { if ($title === 'title') { $title = $product->price . ' ' . $translate->wooTranslate('Credits', get_bloginfo('language')); } echo '<a ' . $class . ' href="javascript:void(0);" onclick="creditdeduct(' . $product->id . ',' . $product->price . ')" >' . $title . '</a>'; } }
public static function actionSingleProduct() { if (static::getPrice() < static::$priceGreaterThanOrEqualTo) { woocommerce_template_single_price(); return; } $product = get_product(); ?> <div itemprop="offers" itemscope itemtype="http://schema.org/Offer"> <p class="price"><?php echo $product->get_price_html(); ?> <span class="francotecnologia_wc_parcpagseg_single_product_price_span"> <?php echo (static::getPrice() > 0 ? static::$language['or'] . ' ' : '') . static::getParceledValue(); ?> </span> </p> <?php if ($product->product_type != 'variable') { echo static::getParceledTable(); } else { $variationList = $product->get_available_variations(); foreach ($variationList as $variation) { $productVariation = new WC_Product_Variation($variation['variation_id']); $defaultVariation = array_diff($variation['attributes'], $product->get_variation_default_attributes()); echo static::getParceledTable($productVariation->get_price(), $variation['variation_id'], empty($defaultVariation)); } } ?> <meta itemprop="price" content="<?php echo $product->get_price(); ?> " /> <meta itemprop="priceCurrency" content="<?php echo get_woocommerce_currency(); ?> " /> <link itemprop="availability" href="http://schema.org/<?php echo $product->is_in_stock() ? static::$language['InStock'] : static::$language['OutOfStock']; ?> " /> </div> <?php }
public static function rac_send_manual_mail() { global $wpdb, $woocommerce, $to, $user_lang; $table_name = $wpdb->prefix . 'rac_abandoncart'; // $emailtemplate_table_name = $wpdb->prefix . 'rac_templates_email'; $abandancart_table_name = $wpdb->prefix . 'rac_abandoncart'; $sender_option_post = stripslashes($_POST['rac_sender_option']); $from_name_post = stripslashes($_POST['rac_from_name']); $from_email_post = stripslashes($_POST['rac_from_email']); $message_post = stripslashes($_POST['rac_message']); $subject_post = stripslashes($_POST['rac_mail_subject']); $anchor_text_post = stripslashes($_POST['rac_anchor_text']); $mail_row_ids = stripslashes($_POST['rac_mail_row_ids']); $row_id_array = explode(',', $mail_row_ids); $mail_template_id_post = isset($_POST['template_id']) ? $_POST['template_id'] : ''; $table_name_email = $wpdb->prefix . 'rac_templates_email'; ?> <style type="text/css"> table { border-collapse: separate; border-spacing: 0; color: #4a4a4d; font: 14px/1.4 "Helvetica Neue", Helvetica, Arial, sans-serif; } th, td { padding: 10px 15px; vertical-align: middle; } thead { background: #395870; background: linear-gradient(#49708f, #293f50); color: #fff; font-size: 11px; text-transform: uppercase; } th:first-child { border-top-left-radius: 5px; text-align: left; } th:last-child { border-top-right-radius: 5px; } tbody tr:nth-child(even) { background: #f0f0f2; } td { border-bottom: 1px solid #cecfd5; border-right: 1px solid #cecfd5; } td:first-child { border-left: 1px solid #cecfd5; } .book-title { color: #395870; display: block; } .text-offset { color: #7c7c80; font-size: 12px; } .item-stock, .item-qty { text-align: center; } .item-price { text-align: right; } .item-multiple { display: block; } tfoot { text-align: right; } tfoot tr:last-child { background: #f0f0f2; color: #395870; font-weight: bold; } tfoot tr:last-child td:first-child { border-bottom-left-radius: 5px; } tfoot tr:last-child td:last-child { border-bottom-right-radius: 5px; } </style> <?php //$mail_temp_row = $wpdb->get_results("SELECT * FROM $table_name_email WHERE id=$template_id_post", OBJECT); $headers = "MIME-Version: 1.0\r\n"; $headers .= "Content-Type: text/html; charset=UTF-8\r\n"; if ($sender_option_post == 'local') { $headers .= FPRacCron::rac_formatted_from_address_local($from_name_post, $from_email_post); $headers .= "Reply-To: " . $from_name_post . " <" . $from_email_post . ">\r\n"; } else { $headers .= FPRacCron::rac_formatted_from_address_woocommerce(); $headers .= "Reply-To: " . get_option('woocommerce_email_from_name') . " <" . get_option('woocommerce_email_from_address') . ">\r\n"; } foreach ($row_id_array as $row_id) { $cart_row = $wpdb->get_results("SELECT * FROM {$table_name} WHERE id={$row_id}", OBJECT); //echo $cart_row[0]->user_id; //For Member $cart_array = maybe_unserialize($cart_row[0]->cart_details); $tablecheckproduct = "<table style='width:100%;border:1px solid #eee;'><thead><tr>"; if (get_option('rac_hide_product_name_product_info_shortcode') != 'yes') { $tablecheckproduct .= "<th style='text-align:left;border:1px solid #eee;padding:12px' scope='col'>" . fp_get_wpml_text('rac_template_product_name', $cart_row[0]->wpml_lang, get_option('rac_product_info_product_name')) . "</th>"; } if (get_option('rac_hide_product_image_product_info_shortcode') != 'yes') { $tablecheckproduct .= "<th style='text-align:left;border:1px solid #eee;padding:12px' scope='col'>" . fp_get_wpml_text('rac_template_product_image', $cart_row[0]->wpml_lang, get_option('rac_product_info_product_image')) . "</th>"; } if (get_option('rac_hide_product_price_product_info_shortcode') != 'yes') { $tablecheckproduct .= "<th style='text-align:left;border:1px solid #eee;padding:12px' scope='col'>" . fp_get_wpml_text('rac_template_product_price', $cart_row[0]->wpml_lang, get_option('rac_product_info_product_price')) . "</th>"; } $tablecheckproduct .= "</tr></thead><tbody>"; if (is_array($cart_array)) { $i = 1; foreach ($cart_array as $cart) { if (is_array($cart)) { foreach ($cart as $inside) { if (is_array($inside)) { foreach ($inside as $product) { if ($cart_row[0]->user_id != '0' && $cart_row[0]->user_id != 'old_order') { if ((double) $woocommerce->version <= (double) '2.0.20') { $objectproduct = get_product($product['product_id']); $objectproductvariable = get_product($product['variation_id']); } else { $objectproduct = new WC_Product($product['product_id']); $objectproductvariable = new WC_Product_Variation($product['variation_id']); } $tablecheckproduct .= "<tr>"; if (get_option('rac_hide_product_name_product_info_shortcode') != 'yes') { $tablecheckproduct .= "<td style='text-align:left;vertical-align:middle;border:1px solid #eee;word-wrap:break-word;padding:12px'>" . get_the_title($product['product_id']) . "</td>"; } if (get_option('rac_hide_product_image_product_info_shortcode') != 'yes') { $tablecheckproduct .= "<td style='text-align:left;vertical-align:middle;border:1px solid #eee;word-wrap:break-word;padding:12px'>" . get_the_post_thumbnail($product['product_id'], array(90, 90)) . "</td>"; } if (get_option('rac_hide_product_price_product_info_shortcode') != 'yes') { $tablecheckproduct .= "<td style='text-align:left;vertical-align:middle;border:1px solid #eee;word-wrap:break-word;padding:12px'>" . FPRacCron::get_rac_formatprice($product['variation_id'] == '' ? $objectproduct->get_price() : $objectproductvariable->get_price()) . "</td>"; } $tablecheckproduct .= "</tr>"; } } } } } else { if ($i == '3') { $get_array_keys = array_keys($cart_array); $product_id = $cart_array[$get_array_keys[0]]['product_id']; $variation_id = $cart_array[$get_array_keys[0]]['variation_id']; if ((double) $woocommerce->version <= (double) '2.0.20') { $objectproduct = get_product($product_id); $objectproductvariable = get_product($variation_id); } else { $objectproduct = new WC_Product($product_id); $objectproductvariable = new WC_Product_Variation($variation_id); } $tablecheckproduct .= "<tr>"; if (get_option('rac_hide_product_name_product_info_shortcode') != 'yes') { $tablecheckproduct .= "<td style='text-align:left;vertical-align:middle;border:1px solid #eee;word-wrap:break-word;padding:12px'>" . get_the_title($product_id) . "</td>"; } if (get_option('rac_hide_product_image_product_info_shortcode') != 'yes') { $tablecheckproduct .= "<td style='text-align:left;vertical-align:middle;border:1px solid #eee;word-wrap:break-word;padding:12px'>" . get_the_post_thumbnail($product_id, array(90, 90)) . "</td>"; } if (get_option('rac_hide_product_price_product_info_shortcode') != 'yes') { $tablecheckproduct .= "<td style='text-align:left;vertical-align:middle;border:1px solid #eee;word-wrap:break-word;padding:12px'>" . FPRacCron::get_rac_formatprice($variation_id == '' ? $objectproduct->get_price() : $objectproductvariable->get_price()) . "</td>"; } $tablecheckproduct .= "</tr>"; } $i++; } } } elseif (is_object($cart_array)) { $order = new WC_Order($cart_array->id); // if ($order->user_id != '') { foreach ($order->get_items() as $products) { if ((double) $woocommerce->version <= (double) '2.0.20') { $objectproduct = get_product($products['product_id']); $objectproductvariable = get_product($products['variation_id']); } else { $objectproduct = new WC_Product($products['product_id']); $objectproductvariable = new WC_Product_Variation($products['variation_id']); } $tablecheckproduct .= "<tr>"; if (get_option('rac_hide_product_name_product_info_shortcode') != 'yes') { $tablecheckproduct .= "<td style='text-align:left;vertical-align:middle;border:1px solid #eee;word-wrap:break-word;padding:12px'>" . get_the_title($products['product_id']) . "</td>"; } if (get_option('rac_hide_product_image_product_info_shortcode') != 'yes') { $tablecheckproduct .= "<td style='text-align:left;vertical-align:middle;border:1px solid #eee;word-wrap:break-word;padding:12px'>" . get_the_post_thumbnail($products['product_id'], array(90, 90)) . "</td>"; } if (get_option('rac_hide_product_price_product_info_shortcode') != 'yes') { $tablecheckproduct .= "<td style='text-align:left;vertical-align:middle;border:1px solid #eee;word-wrap:break-word;padding:12px'>" . FPRacCron::get_rac_formatprice($products['line_total']) . "</td>"; } $tablecheckproduct .= "</tr>"; } //} } $tablecheckproduct .= "</table>"; if ($cart_row[0]->user_id != '0' && $cart_row[0]->user_id != 'old_order') { //echo 'member'; $sent_mail_templates = maybe_unserialize($cart_row[0]->mail_template_id); if (!is_array($sent_mail_templates)) { $sent_mail_templates = array(); // to avoid mail sent/not sent problem for serialization on store } $current_time = current_time('timestamp'); @($cart_url = WC_Cart::get_cart_url()); $url_to_click = esc_url_raw(add_query_arg(array('abandon_cart' => $cart_row[0]->id, 'email_template' => $mail_template_id_post), $cart_url)); if (get_option('rac_cart_link_options') == '1') { $url_to_click = '<a style="color:' . get_option("rac_email_link_color") . '" href="' . $url_to_click . '">' . fp_get_wpml_text('rac_template_' . $mail_template_id_post . '_anchor_text', $cart_row[0]->wpml_lang, $anchor_text_post) . '</a>'; } elseif (get_option('rac_cart_link_options') == '2') { $url_to_click = $url_to_click; } else { $cart_text = fp_get_wpml_text('rac_template_' . $mail_template_id_post . '_anchor_text', $cart_row[0]->wpml_lang, $anchor_text_post); $url_to_click = self::rac_cart_link_button_mode($url_to_click, $cart_text); } //$url_to_click = '<a href="' . $url_to_click . '">' . fp_get_wpml_text('rac_template_' . $mail_template_id_post . '_anchor_text', $cart_row[0]->wpml_lang, $anchor_text_post) . '</a>'; $user = get_userdata($cart_row[0]->user_id); $to = $user->user_email; $user_lang = $cart_row[0]->wpml_lang; $firstname = $user->user_firstname; $lastname = $user->user_lastname; $subject = fp_get_wpml_text('rac_template_' . $mail_template_id_post . '_subject', $cart_row[0]->wpml_lang, $subject_post); $subject = self::shortcode_in_subject($firstname, $lastname, $subject); $message = fp_get_wpml_text('rac_template_' . $mail_template_id_post . '_message', $cart_row[0]->wpml_lang, $message_post); $message = str_replace('{rac.cartlink}', $url_to_click, $message); $message = str_replace('{rac.firstname}', $firstname, $message); $message = str_replace('{rac.lastname}', $lastname, $message); $message = str_replace('{rac.Productinfo}', $tablecheckproduct, $message); if (strpos($message, "{rac.coupon}")) { $coupon_code = FPRacCoupon::rac_create_coupon($user->user_email, $cart_row[0]->cart_abandon_time); $message = str_replace('{rac.coupon}', $coupon_code, $message); //replacing shortcode with coupon code } add_filter('woocommerce_email_footer_text', array('RecoverAbandonCart', 'rac_footer_email_customization')); $message = do_shortcode($message); //shortcode feature if (get_option('rac_email_use_temp_plain') != 'yes') { ob_start(); if (function_exists('wc_get_template')) { wc_get_template('emails/email-header.php', array('email_heading' => $subject)); echo $message; wc_get_template('emails/email-footer.php'); } else { woocommerce_get_template('emails/email-header.php', array('email_heading' => $subject)); echo $message; woocommerce_get_template('emails/email-footer.php'); } $woo_temp_msg = ob_get_clean(); } else { $woo_temp_msg = $message; } if ('wp_mail' == get_option('rac_trouble_mail')) { if (FPRacCron::rac_send_wp_mail($to, $subject, $woo_temp_msg, $headers)) { //wp_mail($to, $subject, $message); $sent_mail_templates[] = $mail_template_id_post; $store_template_id = maybe_serialize($sent_mail_templates); $wpdb->update($abandancart_table_name, array('mail_template_id' => $store_template_id), array('id' => $cart_row[0]->id)); //add to mail log $table_name_logs = $wpdb->prefix . 'rac_email_logs'; $template_used = $mail_template_id_post . '- Manual'; $wpdb->insert($table_name_logs, array("email_id" => $to, "date_time" => $current_time, "rac_cart_id" => $cart_row[0]->id, "template_used" => $template_used)); FPRacCounter::rac_do_mail_count(); } } else { if (FPRacCron::rac_send_mail($to, $subject, $woo_temp_msg, $headers)) { //wp_mail($to, $subject, $message); $sent_mail_templates[] = $mail_template_id_post; $store_template_id = maybe_serialize($sent_mail_templates); $wpdb->update($abandancart_table_name, array('mail_template_id' => $store_template_id), array('id' => $cart_row[0]->id)); //add to mail log $table_name_logs = $wpdb->prefix . 'rac_email_logs'; $template_used = $mail_template_id_post . '- Manual'; $wpdb->insert($table_name_logs, array("email_id" => $to, "date_time" => $current_time, "rac_cart_id" => $cart_row[0]->id, "template_used" => $template_used)); FPRacCounter::rac_do_mail_count(); } } } //End Member //FOR Guest at place order if ($cart_row[0]->user_id === '0' && is_null($cart_row[0]->ip_address)) { // echo 'guest'; $sent_mail_templates = maybe_unserialize($cart_row[0]->mail_template_id); if (!is_array($sent_mail_templates)) { $sent_mail_templates = array(); // to avoid mail sent/not sent problem for serialization on store } $current_time = current_time('timestamp'); @($cart_url = WC_Cart::get_cart_url()); $url_to_click = esc_url_raw(add_query_arg(array('abandon_cart' => $cart_row[0]->id, 'email_template' => $mail_template_id_post, 'guest' => 'yes'), $cart_url)); //$url_to_click = '<a href="' . $url_to_click . '">' . fp_get_wpml_text('rac_template_' . $mail_template_id_post . '_anchor_text', $cart_row[0]->wpml_lang, $anchor_text_post) . '</a>'; if (get_option('rac_cart_link_options') == '1') { $url_to_click = '<a style="color:' . get_option("rac_email_link_color") . '" href="' . $url_to_click . '">' . fp_get_wpml_text('rac_template_' . $mail_template_id_post . '_anchor_text', $cart_row[0]->wpml_lang, $anchor_text_post) . '</a>'; } elseif (get_option('rac_cart_link_options') == '2') { $url_to_click = $url_to_click; } else { $cart_text = fp_get_wpml_text('rac_template_' . $mail_template_id_post . '_anchor_text', $cart_row[0]->wpml_lang, $anchor_text_post); $url_to_click = self::rac_cart_link_button_mode($url_to_click, $cart_text); } // $user = get_userdata($each_cart->user_id); NOT APPLICABLE $order_object = maybe_unserialize($cart_row[0]->cart_details); $to = $order_object->billing_email; $user_lang = $cart_row[0]->wpml_lang; $firstname = $order_object->billing_first_name; $lastname = $order_object->billing_last_name; $subject = self::shortcode_in_subject($firstname, $lastname, $subject_post); $message = str_replace('{rac.cartlink}', $url_to_click, $message_post); $message = str_replace('{rac.firstname}', $firstname, $message); $message = str_replace('{rac.lastname}', $lastname, $message); $message = str_replace('{rac.Productinfo}', $tablecheckproduct, $message); if (strpos($message, "{rac.coupon}")) { $coupon_code = FPRacCoupon::rac_create_coupon($order_object->billing_email, $cart_row[0]->cart_abandon_time); $message = str_replace('{rac.coupon}', $coupon_code, $message); //replacing shortcode with coupon code } $message = do_shortcode($message); //shortcode feature add_filter('woocommerce_email_footer_text', array('RecoverAbandonCart', 'rac_footer_email_customization')); if (get_option('rac_email_use_temp_plain') != 'yes') { ob_start(); if (function_exists('wc_get_template')) { wc_get_template('emails/email-header.php', array('email_heading' => $subject)); echo $message; wc_get_template('emails/email-footer.php'); } else { woocommerce_get_template('emails/email-header.php', array('email_heading' => $subject)); echo $message; woocommerce_get_template('emails/email-footer.php'); } $woo_temp_msg = ob_get_clean(); } else { $woo_temp_msg = $message; } if ('wp_mail' == get_option('rac_trouble_mail')) { if (FPRacCron::rac_send_wp_mail($to, $subject, $woo_temp_msg, $headers)) { // wp_mail($to, $subject, $message); $sent_mail_templates[] = $mail_template_id_post; $store_template_id = maybe_serialize($sent_mail_templates); $wpdb->update($abandancart_table_name, array('mail_template_id' => $store_template_id), array('id' => $cart_row[0]->id)); //add to mail log $table_name_logs = $wpdb->prefix . 'rac_email_logs'; $template_used = $mail_template_id_post . '- Manual'; $wpdb->insert($table_name_logs, array("email_id" => $to, "date_time" => $current_time, "rac_cart_id" => $cart_row[0]->id, "template_used" => $template_used)); FPRacCounter::rac_do_mail_count(); } } else { if (FPRacCron::rac_send_mail($to, $subject, $woo_temp_msg, $headers)) { // wp_mail($to, $subject, $message); $sent_mail_templates[] = $mail_template_id_post; $store_template_id = maybe_serialize($store_template_id); $wpdb->update($abandancart_table_name, array('mail_template_id' => $store_template_id), array('id' => $each_cart->id)); //add to mail log $table_name_logs = $wpdb->prefix . 'rac_email_logs'; $template_used = $mail_template_id_post . '- Manual'; $wpdb->insert($table_name_logs, array("email_id" => $to, "date_time" => $current_time, "rac_cart_id" => $each_cart->id, "template_used" => $template_used)); FPRacCounter::rac_do_mail_count(); } } } //END Guest //GUEST Checkout if ($cart_row[0]->user_id == '0' && !is_null($cart_row[0]->ip_address)) { // echo 'checkout'; $sent_mail_templates = maybe_unserialize($each_cart->mail_template_id); if (!is_array($sent_mail_templates)) { $sent_mail_templates = array(); // to avoid mail sent/not sent problem for serialization on store } $current_time = current_time('timestamp'); @($cart_url = WC_Cart::get_cart_url()); $url_to_click = esc_url_raw(add_query_arg(array('abandon_cart' => $cart_row[0]->id, 'email_template' => $mail_template_id_post, 'guest' => 'yes', 'checkout' => 'yes'), $cart_url)); if (get_option('rac_cart_link_options') == '1') { $url_to_click = '<a style="color:' . get_option("rac_email_link_color") . '" href="' . $url_to_click . '">' . fp_get_wpml_text('rac_template_' . $mail_template_id_post . '_anchor_text', $cart_row[0]->wpml_lang, $anchor_text_post) . '</a>'; } elseif (get_option('rac_cart_link_options') == '2') { $url_to_click = $url_to_click; } else { $cart_text = fp_get_wpml_text('rac_template_' . $mail_template_id_post . '_anchor_text', $cart_row[0]->wpml_lang, $anchor_text_post); $url_to_click = self::rac_cart_link_button_mode($url_to_click, $cart_text); } // $user = get_userdata($each_cart->user_id); NOT APPLICABLE $order_object = maybe_unserialize($cart_row[0]->cart_details); $to = $order_object['visitor_mail']; $user_lang = $cart_row[0]->wpml_lang; $firstname = $order_object['first_name']; $lastname = $order_object['last_name']; $message = str_replace('{rac.cartlink}', $url_to_click, $message_post); $subject = self::shortcode_in_subject($firstname, $lastname, $subject_post); $message = str_replace('{rac.firstname}', $firstname, $message); $message = str_replace('{rac.lastname}', $lastname, $message); $message = str_replace('{rac.Productinfo}', $tablecheckproduct, $message); if (strpos($message, "{rac.coupon}")) { $coupon_code = FPRacCoupon::rac_create_coupon($order_object['visitor_mail'], $cart_row[0]->cart_abandon_time); $message = str_replace('{rac.coupon}', $coupon_code, $message); //replacing shortcode with coupon code } $message = do_shortcode($message); //shortcode feature if (get_option('rac_email_use_temp_plain') != 'yes') { ob_start(); if (function_exists('wc_get_template')) { wc_get_template('emails/email-header.php', array('email_heading' => $subject)); echo $message; wc_get_template('emails/email-footer.php'); } else { woocommerce_get_template('emails/email-header.php', array('email_heading' => $subject)); echo $message; woocommerce_get_template('emails/email-footer.php'); } $woo_temp_msg = ob_get_clean(); } else { $woo_temp_msg = $message; } if ('wp_mail' == get_option('rac_trouble_mail')) { if (FPRacCron::rac_send_wp_mail($to, $subject, $woo_temp_msg, $headers)) { // wp_mail($to, $subject, $message); $sent_mail_templates[] = $mail_template_id_post; $store_template_id = maybe_serialize($sent_mail_templates); $wpdb->update($abandancart_table_name, array('mail_template_id' => $store_template_id), array('id' => $cart_row[0]->id)); //add to mail log $table_name_logs = $wpdb->prefix . 'rac_email_logs'; $template_used = $mail_template_id_post . '- Manual'; $wpdb->insert($table_name_logs, array("email_id" => $to, "date_time" => $current_time, "rac_cart_id" => $cart_row[0]->id, "template_used" => $template_used)); FPRacCounter::rac_do_mail_count(); } } else { if (FPRacCron::rac_send_mail($to, $subject, $woo_temp_msg, $headers)) { // wp_mail($to, $subject, $message); $sent_mail_templates[] = $emails->id; $store_template_id = maybe_serialize($sent_mail_templates); $wpdb->update($abandancart_table_name, array('mail_template_id' => $store_template_id), array('id' => $cart_row[0]->id)); //add to mail log $table_name_logs = $wpdb->prefix . 'rac_email_logs'; $template_used = $mail_template_id_post . '- Manual'; $wpdb->insert($table_name_logs, array("email_id" => $to, "date_time" => $current_time, "rac_cart_id" => $cart_row[0]->id, "template_used" => $template_used)); FPRacCounter::rac_do_mail_count(); } } } //END Checkout //Order Updated if ($cart_row[0]->user_id == 'old_order' && is_null($cart_row[0]->ip_address)) { // echo 'order'; $sent_mail_templates = maybe_unserialize($each_cart->mail_template_id); $current_time = current_time('timestamp'); @($cart_url = WC_Cart::get_cart_url()); $url_to_click = esc_url_raw(add_query_arg(array('abandon_cart' => $cart_row[0]->id, 'email_template' => $mail_template_id_post, 'old_order' => 'yes'), $cart_url)); //$url_to_click = '<a href="' . $url_to_click . '">' . fp_get_wpml_text('rac_template_' . $mail_template_id_post . '_anchor_text', $cart_row[0]->wpml_lang, $anchor_text_post) . '</a>'; if (get_option('rac_cart_link_options') == '1') { $url_to_click = '<a style="color:' . get_option("rac_email_link_color") . '" href="' . $url_to_click . '">' . fp_get_wpml_text('rac_template_' . $mail_template_id_post . '_anchor_text', $cart_row[0]->wpml_lang, $anchor_text_post) . '</a>'; } elseif (get_option('rac_cart_link_options') == '2') { $url_to_click = $url_to_click; } else { $cart_text = fp_get_wpml_text('rac_template_' . $mail_template_id_post . '_anchor_text', $cart_row[0]->wpml_lang, $anchor_text_post); $url_to_click = self::rac_cart_link_button_mode($url_to_click, $cart_text); } // $user = get_userdata($each_cart->user_id); NOT APPLICABLE $order_object = maybe_unserialize($cart_row[0]->cart_details); $to = $order_object->billing_email; $user_lang = $cart_row[0]->wpml_lang; $firstname = $order_object->billing_first_name; $lastname = $order_object->billing_last_name; $message = str_replace('{rac.cartlink}', $url_to_click, $message_post); $subject = self::shortcode_in_subject($firstname, $lastname, $subject_post); $message = str_replace('{rac.firstname}', $firstname, $message); $message = str_replace('{rac.lastname}', $lastname, $message); $message = str_replace('{rac.Productinfo}', $tablecheckproduct, $message); if (strpos($message, "{rac.coupon}")) { $coupon_code = FPRacCoupon::rac_create_coupon($order_object->billing_email, $cart_row[0]->cart_abandon_time); $message = str_replace('{rac.coupon}', $coupon_code, $message); //replacing shortcode with coupon code } $message = do_shortcode($message); //shortcode feature if (get_option('rac_email_use_temp_plain') != 'yes') { ob_start(); if (function_exists('wc_get_template')) { wc_get_template('emails/email-header.php', array('email_heading' => $subject)); echo $message; wc_get_template('emails/email-footer.php'); } else { woocommerce_get_template('emails/email-header.php', array('email_heading' => $subject)); echo $message; woocommerce_get_template('emails/email-footer.php'); } $woo_temp_msg = ob_get_clean(); } else { $woo_temp_msg = $message; } if ('wp_mail' == get_option('rac_trouble_mail')) { if (FPRacCron::rac_send_wp_mail($to, $subject, $woo_temp_msg, $headers)) { // wp_mail($to, $subject, $message); $sent_mail_templates[] = $mail_template_id_post; $store_template_id = maybe_serialize($sent_mail_templates); $wpdb->update($abandancart_table_name, array('mail_template_id' => $store_template_id), array('id' => $cart_row[0]->id)); //add to mail log $table_name_logs = $wpdb->prefix . 'rac_email_logs'; $template_used = $mail_template_id_post . '- Manual'; $wpdb->insert($table_name_logs, array("email_id" => $to, "date_time" => $current_time, "rac_cart_id" => $cart_row[0]->id, "template_used" => $template_used)); FPRacCounter::rac_do_mail_count(); } } else { if (FPRacCron::rac_send_mail($to, $subject, $woo_temp_msg, $headers)) { // wp_mail($to, $subject, $message); $sent_mail_templates[] = $mail_template_id_post; $store_template_id = maybe_serialize($sent_mail_templates); $wpdb->update($abandancart_table_name, array('mail_template_id' => $store_template_id), array('id' => $cart_row[0]->id)); //add to mail log $table_name_logs = $wpdb->prefix . 'rac_email_logs'; $template_used = $mail_template_id_post . '- Manual'; $wpdb->insert($table_name_logs, array("email_id" => $to, "date_time" => $current_time, "rac_cart_id" => $cart_row[0]->id, "template_used" => $template_used)); FPRacCounter::rac_do_mail_count(); } } } // var_dump($cart_row[0]->user_id); } exit; }
?> " data-instock="<?php echo $variation->is_in_stock() ? '1' : '0'; ?> " data-backorders="<?php echo $variation->backorders_allowed() ? '1' : '0'; ?> " data-max="<?php echo $variation->get_stock_quantity(); ?> " data-price="<?php echo $variation->get_price(); ?> " data-vmsg="<?php echo $vmsg; ?> " title="<?php echo esc_attr(woocommerce_bulk_variations_get_price($variation->get_price())); ?> " id="qty_input_<?php echo $cell_index; ?> " data-column="<?php
$upgradeamount = -1; // Need to handle the top item with contact us. $upgradeVariation = -1; // Need to handle unknown cost... break; } } // Update for manual processing Add10 (10 ) if ($auto10 == 0 && get_field('add10', get_the_ID()) == 1 && $upgradeamount >= 0) { $addupgrade_cost = $upgrade_plus10; $upgradeamount = $upgradeamount + 10; } // This does the math for the cost - only if not auto upgraded if ($upgradeVariation >= 0) { $_product = new WC_Product_Variation($upgradeVariation); $basecost = $_product->get_price(); $upgradecost = intval($basecost) - $totalPrice + $addupgrade_cost; } else { $basecost = -1; $upgradecost = -1; // Handling the overages } } } //Setting the counts if ($upgradeamount >= 0) { $the_final_count = strtoupper($upgradeamount); } // Updating the DB if ($upgradedb > 0) { __update_post_meta(get_the_ID(), 'card_quantity', $value = $upgradedb);
public function get_RP_WCDPD($product, $field_price = null, $cart_item_key = null) { $price = null; if (class_exists('RP_WCDPD') && class_exists('RP_WCDPD_Pricing') && !empty($GLOBALS['RP_WCDPD'])) { $tm_RP_WCDPD = $GLOBALS['RP_WCDPD']; $selected_rule = null; if ($field_price !== null && $cart_item_key !== null) { return $this->get_RP_WCDPD_single($field_price, $cart_item_key, $tm_RP_WCDPD->pricing); } $dpd_version_compare = version_compare(RP_WCDPD_VERSION, '1.0.13', '<'); // Iterate over pricing rules and use the first one that has this product in conditions (or does not have if condition "not in list") if (isset($tm_RP_WCDPD->opt['pricing']['sets']) && count($tm_RP_WCDPD->opt['pricing']['sets'])) { foreach ($tm_RP_WCDPD->opt['pricing']['sets'] as $rule_key => $rule) { if ($rule['method'] == 'quantity' && ($validated_rule = RP_WCDPD_Pricing::validate_rule($rule))) { if ($dpd_version_compare) { if ($validated_rule['selection_method'] == 'all' && $tm_RP_WCDPD->user_matches_rule($validated_rule['user_method'], $validated_rule['roles'])) { $selected_rule = $validated_rule; break; } if ($validated_rule['selection_method'] == 'categories_include' && count(array_intersect($tm_RP_WCDPD->get_product_categories($product->id), $validated_rule['categories'])) > 0 && $tm_RP_WCDPD->user_matches_rule($validated_rule['user_method'], $validated_rule['roles'])) { $selected_rule = $validated_rule; break; } if ($validated_rule['selection_method'] == 'categories_exclude' && count(array_intersect($tm_RP_WCDPD->get_product_categories($product->id), $validated_rule['categories'])) == 0 && $tm_RP_WCDPD->user_matches_rule($validated_rule['user_method'], $validated_rule['roles'])) { $selected_rule = $validated_rule; break; } if ($validated_rule['selection_method'] == 'products_include' && in_array($product->id, $validated_rule['products']) && $tm_RP_WCDPD->user_matches_rule($validated_rule['user_method'], $validated_rule['roles'])) { $selected_rule = $validated_rule; break; } if ($validated_rule['selection_method'] == 'products_exclude' && !in_array($product->id, $validated_rule['products']) && $tm_RP_WCDPD->user_matches_rule($validated_rule['user_method'], $validated_rule['roles'])) { $selected_rule = $validated_rule; break; } } else { if ($validated_rule['selection_method'] == 'all' && $tm_RP_WCDPD->user_matches_rule($validated_rule)) { $selected_rule = $validated_rule; break; } if ($validated_rule['selection_method'] == 'categories_include' && count(array_intersect($tm_RP_WCDPD->get_product_categories($product->id), $validated_rule['categories'])) > 0 && $tm_RP_WCDPD->user_matches_rule($validated_rule)) { $selected_rule = $validated_rule; break; } if ($validated_rule['selection_method'] == 'categories_exclude' && count(array_intersect($tm_RP_WCDPD->get_product_categories($product->id), $validated_rule['categories'])) == 0 && $tm_RP_WCDPD->user_matches_rule($validated_rule)) { $selected_rule = $validated_rule; break; } if ($validated_rule['selection_method'] == 'products_include' && in_array($product->id, $validated_rule['products']) && $tm_RP_WCDPD->user_matches_rule($validated_rule)) { $selected_rule = $validated_rule; break; } if ($validated_rule['selection_method'] == 'products_exclude' && !in_array($product->id, $validated_rule['products']) && $tm_RP_WCDPD->user_matches_rule($validated_rule)) { $selected_rule = $validated_rule; break; } } } } } if (is_array($selected_rule)) { // Quantity if ($selected_rule['method'] == 'quantity' && isset($selected_rule['pricing']) && in_array($selected_rule['quantities_based_on'], array('exclusive_product', 'exclusive_variation', 'exclusive_configuration'))) { if ($product->product_type == 'variable' || $product->product_type == 'variable-subscription') { $product_variations = $product->get_available_variations(); } // For variable products only - check if prices differ for different variations $multiprice_variable_product = false; if (($product->product_type == 'variable' || $product->product_type == 'variable') && !empty($product_variations)) { $last_product_variation = array_slice($product_variations, -1); $last_product_variation_object = new WC_Product_Variable($last_product_variation[0]['variation_id']); $last_product_variation_price = $last_product_variation_object->get_price(); foreach ($product_variations as $variation) { $variation_object = new WC_Product_Variable($variation['variation_id']); if ($variation_object->get_price() != $last_product_variation_price) { $multiprice_variable_product = true; } } } if ($multiprice_variable_product) { $variation_table_data = array(); foreach ($product_variations as $variation) { $variation_product = new WC_Product_Variation($variation['variation_id']); $variation_table_data[$variation['variation_id']] = $tm_RP_WCDPD->pricing_table_calculate_adjusted_prices($selected_rule['pricing'], $variation_product->get_price()); } $price = array(); $price['is_multiprice'] = true; $price['rules'] = $variation_table_data; } else { if ($product->product_type == 'variable' && !empty($product_variations)) { $variation_product = new WC_Product_Variation($last_product_variation[0]['variation_id']); $table_data = $tm_RP_WCDPD->pricing_table_calculate_adjusted_prices($selected_rule['pricing'], $variation_product->get_price()); } else { $table_data = $tm_RP_WCDPD->pricing_table_calculate_adjusted_prices($selected_rule['pricing'], $product->get_price()); } $price = array(); $price['is_multiprice'] = false; $price['rules'] = $table_data; } } } } if ($field_price !== null) { $price = $field_price; } return $price; }
function get_option_price() { //nm_personalizedproduct_pa($_REQUEST); exit; //echo wc_price(intval($_REQUEST['price1'])); extract($_REQUEST); $html = ''; $option_total_price = 0; $fixed_fee = 0; $fixed_fee_meta = array(); if ($optionprices) { foreach ($optionprices as $pair) { $option = isset($pair['option']) ? $pair['option'] : ''; $price = isset($pair['price']) ? $pair['price'] : ''; $onetime = isset($pair['isfixed']) ? $pair['isfixed'] : ''; $onetime_taxable = isset($pair['fixedfeetaxable']) ? $pair['fixedfeetaxable'] : ''; $html .= $option . ' ' . woocommerce_price($price) . '<br>'; if ($onetime) { $fixed_fee += $price; $fixed_fee_meta[$option] = array('fee' => $price, 'taxable' => $onetime_taxable); } else { $option_total_price += $price; } } } $pricematrix = isset($_REQUEST['pricematrix']) ? $_REQUEST['pricematrix'] : ''; if ($pricematrix) { $baseprice = $this->get_matrix_price($qty, stripslashes($pricematrix)); } if ($pricematrix) { $baseprice = $this->get_matrix_price($qty, stripslashes($pricematrix)); } //checking if it's a variation //getting options $variation_price = ''; if ($variation_id != '') { $product_variation = new WC_Product_Variation($variation_id); $variation_price = $product_variation->get_price(); $baseprice = $variation_price; } $total_price = $option_total_price + $baseprice; $html .= '<strong>' . __('Total: ', 'nm-personalizedproduct') . woocommerce_price($total_price) . '</strong>'; $option_prices = array('prices_html' => $html, 'option_total' => $option_total_price, 'total_price' => $total_price, 'onetime_fee' => $fixed_fee, 'onetime_meta' => $fixed_fee_meta, 'variation_price' => $variation_price, 'display_price_hide' => $single_form->dynamic_price_display); echo json_encode($option_prices); die(0); }
/** * */ public function get_bundle_price($price, $values) { // set starting price $price = 0; // go through each item foreach ($values['stamp'] as $item) { // determine the type, create new object for each, then get its price switch ($item['type']) { case 'variable': $prod = new WC_Product_Variation($item['product_id']); $p_price = $prod->get_price(); break; default: // simple $prod = new WC_Product_Simple($item['product_id']); $p_price = $prod->get_price(); break; } // if there is a discount if ($item['discount'] != 0) { // subtract the discount from the price $p_price = $p_price - $item['discount'] / 100 * $p_price; } // add the item's price to the total $price = $price + $p_price * $item['quantity']; } // format and return return number_format($price, 2); }
public static function fp_rac_cron_job_mailing() { global $wpdb; global $woocommerce; global $to; global $user_lang; $emailtemplate_table_name = $wpdb->prefix . 'rac_templates_email'; $abandancart_table_name = $wpdb->prefix . 'rac_abandoncart'; $email_templates = $wpdb->get_results("SELECT * FROM {$emailtemplate_table_name}"); //all email templates $abandon_carts = $wpdb->get_results("SELECT * FROM {$abandancart_table_name} WHERE cart_status='ABANDON' AND user_id!='0' AND completed IS NULL"); //Selected only cart which are not completed // For Members foreach ($abandon_carts as $each_cart) { foreach ($email_templates as $emails) { if ($emails->status == "ACTIVE") { $cart_array = maybe_unserialize($each_cart->cart_details); $tablecheckproduct = "<table style='width:100%;border:1px solid #eee;'><thead><tr>"; if (get_option('rac_hide_product_name_product_info_shortcode') != 'yes') { $tablecheckproduct .= "<th style='text-align:left;border:1px solid #eee;padding:12px' scope='col'>" . fp_get_wpml_text('rac_template_product_name', $each_cart->wpml_lang, get_option('rac_product_info_product_name')) . "</th>"; } if (get_option('rac_hide_product_image_product_info_shortcode') != 'yes') { $tablecheckproduct .= "<th style='text-align:left;border:1px solid #eee;padding:12px' scope='col'>" . fp_get_wpml_text('rac_template_product_image', $each_cart->wpml_lang, get_option('rac_product_info_product_image')) . "</th>"; } if (get_option('rac_hide_product_price_product_info_shortcode') != 'yes') { $tablecheckproduct .= "<th style='text-align:left;border:1px solid #eee;padding:12px' scope='col'>" . fp_get_wpml_text('rac_template_product_price', $each_cart->wpml_lang, get_option('rac_product_info_product_price')) . "</th>"; } $tablecheckproduct .= "</tr></thead><tbody>"; if (is_array($cart_array)) { foreach ($cart_array as $cart) { foreach ($cart as $inside) { foreach ($inside as $product) { if ((double) $woocommerce->version <= (double) '2.0.20') { $objectproduct = get_product($product['product_id']); $objectproductvariable = get_product($product['variation_id']); } else { $objectproduct = new WC_Product($product['product_id']); $objectproductvariable = new WC_Product_Variation($product['variation_id']); } $tablecheckproduct .= "<tr>"; if (get_option('rac_hide_product_name_product_info_shortcode') != 'yes') { $tablecheckproduct .= "<td style='text-align:left;vertical-align:middle;border:1px solid #eee;word-wrap:break-word;padding:12px'>" . get_the_title($product['product_id']) . "</td>"; } if (get_option('rac_hide_product_image_product_info_shortcode') != 'yes') { $tablecheckproduct .= "<td style='text-align:left;vertical-align:middle;border:1px solid #eee;word-wrap:break-word;padding:12px'>" . get_the_post_thumbnail($product['product_id'], array(90, 90)) . "</td>"; } if (get_option('rac_hide_product_price_product_info_shortcode') != 'yes') { $tablecheckproduct .= "<td style='text-align:left;vertical-align:middle;border:1px solid #eee;word-wrap:break-word;padding:12px'>" . self::get_rac_formatprice($product['variation_id'] == '' ? $objectproduct->get_price() : $objectproductvariable->get_price()) . "</td>"; } $tablecheckproduct .= "</tr>"; } } } /* $tablecheckproduct .= "It is from Array"; $dump = print_r($cart_array, true); $tablecheckproduct .= $dump; */ } elseif (is_object($cart_array)) { $order = new WC_Order($cart_array->id); if ($order->user_id != '') { foreach ($order->get_items() as $products) { if ((double) $woocommerce->version <= (double) '2.0.20') { $objectproduct = get_product($products['product_id']); $objectproductvariable = get_product($products['variation_id']); } else { $objectproduct = new WC_Product($products['product_id']); $objectproductvariable = new WC_Product_Variation($products['variation_id']); } $tablecheckproduct .= "<tr>"; if (get_option('rac_hide_product_name_product_info_shortcode') != 'yes') { $tablecheckproduct .= "<td style='text-align:left;vertical-align:middle;border:1px solid #eee;word-wrap:break-word;padding:12px'>" . get_the_title($products['product_id']) . "</td>"; } if (get_option('rac_hide_product_image_product_info_shortcode') != 'yes') { $tablecheckproduct .= "<td style='text-align:left;vertical-align:middle;border:1px solid #eee;word-wrap:break-word;padding:12px'>" . get_the_post_thumbnail($products['product_id'], array(90, 90)) . "</td>"; } if (get_option('rac_hide_product_price_product_info_shortcode') != 'yes') { $tablecheckproduct .= "<td style='text-align:left;vertical-align:middle;border:1px solid #eee;word-wrap:break-word;padding:12px'>" . self::get_rac_formatprice($products['variation_id'] == '' ? $objectproduct->get_price() : $objectproductvariable->get_price()) . "</td>"; } $tablecheckproduct .= "</tr>"; } } /* $tablecheckproduct .= "It is from Object"; $tablecheckproduct .= var_dump($cart_array); */ } $tablecheckproduct .= "</table>"; if (get_option('rac_email_use_members') == 'yes') { if (empty($each_cart->mail_template_id)) { // IF EMPTY IT IS NOT SENT FOR ANY SINGLE TEMPLATE if ($emails->sending_type == 'hours') { $duration = $emails->sending_duration * 3600; } else { if ($emails->sending_type == 'minutes') { $duration = $emails->sending_duration * 60; } else { if ($emails->sending_type == 'days') { $duration = $emails->sending_duration * 86400; } } } //duration is finished $cut_off_time = $each_cart->cart_abandon_time + $duration; $current_time = current_time('timestamp'); if ($current_time > $cut_off_time) { //$cart_url = $woocommerce->cart->get_cart_url(); //$objectcart = new WC_Cart(); @($cart_url = WC_Cart::get_cart_url()); $url_to_click = esc_url_raw(add_query_arg(array('abandon_cart' => $each_cart->id, 'email_template' => $emails->id), $cart_url)); if (get_option('rac_cart_link_options') == '1') { $url_to_click = '<a style="color:' . get_option("rac_email_link_color") . '" href="' . $url_to_click . '">' . fp_get_wpml_text('rac_template_' . $emails->id . '_anchor_text', $each_cart->wpml_lang, $emails->anchor_text) . '</a>'; } elseif (get_option('rac_cart_link_options') == '2') { $url_to_click = $url_to_click; } else { $cart_Text = fp_get_wpml_text('rac_template_' . $emails->id . '_anchor_text', $each_cart->wpml_lang, $emails->anchor_text); $url_to_click = RecoverAbandonCart::rac_cart_link_button_mode($url_to_click, $cart_Text); } $user = get_userdata($each_cart->user_id); $to = $user->user_email; $user_lang = $each_cart->wpml_lang; $subject = fp_get_wpml_text('rac_template_' . $emails->id . '_subject', $each_cart->wpml_lang, $emails->subject); $firstname = $user->user_firstname; $lastname = $user->user_lastname; $message = fp_get_wpml_text('rac_template_' . $emails->id . '_message', $each_cart->wpml_lang, $emails->message); $subject = RecoverAbandonCart::shortcode_in_subject($firstname, $lastname, $subject); $message = str_replace('{rac.cartlink}', $url_to_click, $message); $message = str_replace('{rac.firstname}', $firstname, $message); $message = str_replace('{rac.lastname}', $lastname, $message); $message = str_replace('{rac.Productinfo}', $tablecheckproduct, $message); if (strpos($message, "{rac.coupon}")) { $coupon_code = FPRacCoupon::rac_create_coupon($user->user_email, $each_cart->cart_abandon_time); $message = str_replace('{rac.coupon}', $coupon_code, $message); //replacing shortcode with coupon code } add_filter('woocommerce_email_footer_text', array('RecoverAbandonCart', 'rac_footer_email_customization')); $message = do_shortcode($message); //shortcode feature if (get_option('rac_email_use_temp_plain') != 'yes') { ob_start(); if (function_exists('wc_get_template')) { wc_get_template('emails/email-header.php', array('email_heading' => $subject)); echo $message; wc_get_template('emails/email-footer.php'); } else { woocommerce_get_template('emails/email-header.php', array('email_heading' => $subject)); echo $message; woocommerce_get_template('emails/email-footer.php'); } $woo_temp_msg = ob_get_clean(); } else { $woo_temp_msg = $message; } $headers = "MIME-Version: 1.0\r\n"; $headers .= "Content-Type: text/html; charset=UTF-8\r\n"; if ($emails->sender_opt == 'local') { $headers .= self::rac_formatted_from_address_local($emails->from_name, $emails->from_email); $headers .= "Reply-To: " . $emails->from_name . "<" . $emails->from_email . ">\r\n"; } else { $headers .= self::rac_formatted_from_address_woocommerce(); $headers .= "Reply-To: " . get_option('woocommerce_email_from_name') . " <" . get_option('woocommerce_email_from_address') . ">\r\n"; } if ($each_cart->sending_status == 'SEND') { //condition to check start/stop mail sending if ('wp_mail' == get_option('rac_trouble_mail')) { if (self::rac_send_wp_mail($to, $subject, $woo_temp_msg, $headers)) { // wp_mail($to, $subject, $message); $store_template_id = array($emails->id); $store_template_id = maybe_serialize($store_template_id); $wpdb->update($abandancart_table_name, array('mail_template_id' => $store_template_id), array('id' => $each_cart->id)); //add to mail log $table_name_logs = $wpdb->prefix . 'rac_email_logs'; $wpdb->insert($table_name_logs, array("email_id" => $to, "date_time" => $current_time, "rac_cart_id" => $each_cart->id, "template_used" => $emails->id)); FPRacCounter::rac_do_mail_count(); } } else { if (self::rac_send_mail($to, $subject, $woo_temp_msg, $headers)) { // wp_mail($to, $subject, $message); $store_template_id = array($emails->id); $store_template_id = maybe_serialize($store_template_id); $wpdb->update($abandancart_table_name, array('mail_template_id' => $store_template_id), array('id' => $each_cart->id)); //add to mail log $table_name_logs = $wpdb->prefix . 'rac_email_logs'; $wpdb->insert($table_name_logs, array("email_id" => $to, "date_time" => $current_time, "rac_cart_id" => $each_cart->id, "template_used" => $emails->id)); FPRacCounter::rac_do_mail_count(); } } } } } elseif (!empty($each_cart->mail_template_id)) { $sent_mail_templates = maybe_unserialize($each_cart->mail_template_id); if (!in_array($emails->id, (array) $sent_mail_templates)) { if ($emails->sending_type == 'hours') { $duration = $emails->sending_duration * 3600; } else { if ($emails->sending_type == 'minutes') { $duration = $emails->sending_duration * 60; } else { if ($emails->sending_type == 'days') { $duration = $emails->sending_duration * 86400; } } } //duration is finished $cut_off_time = $each_cart->cart_abandon_time + $duration; $current_time = current_time('timestamp'); if ($current_time > $cut_off_time) { @($cart_url = WC_Cart::get_cart_url()); $url_to_click = esc_url_raw(add_query_arg(array('abandon_cart' => $each_cart->id, 'email_template' => $emails->id), $cart_url)); if (get_option('rac_cart_link_options') == '1') { $url_to_click = '<a style="color:' . get_option("rac_email_link_color") . '" href="' . $url_to_click . '">' . fp_get_wpml_text('rac_template_' . $emails->id . '_anchor_text', $each_cart->wpml_lang, $emails->anchor_text) . '</a>'; } elseif (get_option('rac_cart_link_options') == '2') { $url_to_click = $url_to_click; } else { $cart_Text = fp_get_wpml_text('rac_template_' . $emails->id . '_anchor_text', $each_cart->wpml_lang, $emails->anchor_text); $url_to_click = RecoverAbandonCart::rac_cart_link_button_mode($url_to_click, $cart_Text); } $user = get_userdata($each_cart->user_id); $to = $user->user_email; $user_lang = $each_cart->wpml_lang; $subject = fp_get_wpml_text('rac_template_' . $emails->id . '_subject', $each_cart->wpml_lang, $emails->subject); $firstname = $user->user_firstname; $lastname = $user->user_lastname; $message = fp_get_wpml_text('rac_template_' . $emails->id . '_message', $each_cart->wpml_lang, $emails->message); $subject = RecoverAbandonCart::shortcode_in_subject($firstname, $lastname, $subject); $message = str_replace('{rac.cartlink}', $url_to_click, $message); $message = str_replace('{rac.firstname}', $firstname, $message); $message = str_replace('{rac.lastname}', $lastname, $message); $message = str_replace('{rac.Productinfo}', $tablecheckproduct, $message); if (strpos($message, "{rac.coupon}")) { $coupon_code = FPRacCoupon::rac_create_coupon($user->user_email, $each_cart->cart_abandon_time); $message = str_replace('{rac.coupon}', $coupon_code, $message); //replacing shortcode with coupon code } add_filter('woocommerce_email_footer_text', array('RecoverAbandonCart', 'rac_footer_email_customization')); $message = do_shortcode($message); //shortcode feature if (get_option('rac_email_use_temp_plain') != 'yes') { ob_start(); if (function_exists('wc_get_template')) { wc_get_template('emails/email-header.php', array('email_heading' => $subject)); echo $message; wc_get_template('emails/email-footer.php'); } else { woocommerce_get_template('emails/email-header.php', array('email_heading' => $subject)); echo $message; woocommerce_get_template('emails/email-footer.php'); } $woo_temp_msg = ob_get_clean(); } else { $woo_temp_msg = $message; } $headers = "MIME-Version: 1.0\r\n"; $headers .= "Content-Type: text/html; charset=UTF-8\r\n"; if ($emails->sender_opt == 'local') { $headers .= self::rac_formatted_from_address_local($emails->from_name, $emails->from_email); $headers .= "Reply-To: " . $emails->from_name . " <" . $emails->from_email . ">\r\n"; } else { $headers .= self::rac_formatted_from_address_woocommerce(); $headers .= "Reply-To: " . get_option('woocommerce_email_from_name') . "<" . get_option('woocommerce_email_from_address') . ">\r\n"; } if ($each_cart->sending_status == 'SEND') { //condition to check start/stop mail sending if ('wp_mail' == get_option('rac_trouble_mail')) { if (self::rac_send_wp_mail($to, $subject, $woo_temp_msg, $headers)) { //wp_mail($to, $subject, $message); $sent_mail_templates[] = $emails->id; $store_template_id = maybe_serialize($sent_mail_templates); $wpdb->update($abandancart_table_name, array('mail_template_id' => $store_template_id), array('id' => $each_cart->id)); //add to mail log $table_name_logs = $wpdb->prefix . 'rac_email_logs'; $wpdb->insert($table_name_logs, array("email_id" => $to, "date_time" => $current_time, "rac_cart_id" => $each_cart->id, "template_used" => $emails->id)); FPRacCounter::rac_do_mail_count(); } } else { if (self::rac_send_mail($to, $subject, $woo_temp_msg, $headers)) { //wp_mail($to, $subject, $message); $sent_mail_templates[] = $emails->id; $store_template_id = maybe_serialize($sent_mail_templates); $wpdb->update($abandancart_table_name, array('mail_template_id' => $store_template_id), array('id' => $each_cart->id)); //add to mail log $table_name_logs = $wpdb->prefix . 'rac_email_logs'; $wpdb->insert($table_name_logs, array("email_id" => $to, "date_time" => $current_time, "rac_cart_id" => $each_cart->id, "template_used" => $emails->id)); FPRacCounter::rac_do_mail_count(); } } } } } } } } } } // FOR GUEST if (get_option('rac_email_use_guests') == 'yes') { $abandon_carts = $wpdb->get_results("SELECT * FROM {$abandancart_table_name} WHERE cart_status='ABANDON' AND user_id='0' AND ip_address IS NULL AND completed IS NULL"); //Selected only cart which are not completed foreach ($abandon_carts as $each_cart) { foreach ($email_templates as $emails) { if ($emails->status == "ACTIVE") { $cart_array = maybe_unserialize($each_cart->cart_details); $tablecheckproduct = "<table style='width:100%;border:1px solid #eee;'><thead><tr>"; if (get_option('rac_hide_product_name_product_info_shortcode') != 'yes') { $tablecheckproduct .= "<th style='text-align:left;border:1px solid #eee;padding:12px' scope='col'>" . fp_get_wpml_text('rac_template_product_name', $each_cart->wpml_lang, get_option('rac_product_info_product_name')) . "</th>"; } if (get_option('rac_hide_product_image_product_info_shortcode') != 'yes') { $tablecheckproduct .= "<th style='text-align:left;border:1px solid #eee;padding:12px' scope='col'>" . fp_get_wpml_text('rac_template_product_image', $each_cart->wpml_lang, get_option('rac_product_info_product_image')) . "</th>"; } if (get_option('rac_hide_product_price_product_info_shortcode') != 'yes') { $tablecheckproduct .= "<th style='text-align:left;border:1px solid #eee;padding:12px' scope='col'>" . fp_get_wpml_text('rac_template_product_price', $each_cart->wpml_lang, get_option('rac_product_info_product_price')) . "</th>"; } $tablecheckproduct .= "</tr></thead><tbody>"; $order = new WC_Order($cart_array->id); $products = $order->get_items(); //var_dump($products); /* $tablecheckproduct .= "It is from Guest0 Object or Array"; $dump = print_r($cart_array, true); $tablecheckproduct .= "<pre>"; $tablecheckproduct .= $dump; $tablecheckproduct .= "</pre>"; */ foreach ($products as $each_product) { if ((double) $woocommerce->version <= (double) '2.0.20') { $objectproduct = get_product($each_product['product_id']); $objectproductvariable = get_product($each_product['variation_id']); } else { $objectproduct = new WC_Product($each_product['product_id']); $objectproductvariable = new WC_Product_Variable($each_product['variation_id']); } $tablecheckproduct .= "<tr>"; if (get_option('rac_hide_product_name_product_info_shortcode') != 'yes') { $tablecheckproduct .= "<td style='text-align:left;vertical-align:middle;border:1px solid #eee;word-wrap:break-word;padding:12px'>" . get_the_title($each_product['product_id']) . "</td>"; } if (get_option('rac_hide_product_image_product_info_shortcode') != 'yes') { $tablecheckproduct .= "<td style='text-align:left;vertical-align:middle;border:1px solid #eee;word-wrap:break-word;padding:12px'>" . get_the_post_thumbnail($each_product['product_id'], array(90, 90)) . "</td>"; } if (get_option('rac_hide_product_price_product_info_shortcode') != 'yes') { $tablecheckproduct .= "<td style='text-align:left;vertical-align:middle;border:1px solid #eee;word-wrap:break-word;padding:12px'>" . self::get_rac_formatprice($each_product['variation_id'] == '' ? $objectproduct->get_price() : $objectproductvariable->get_price()) . "</td>"; } $tablecheckproduct .= "</tr>"; } $tablecheckproduct .= "</table>"; if (empty($each_cart->mail_template_id)) { // IF EMPTY IT IS NOT SENT FOR ANY SINGLE TEMPLATE if ($emails->sending_type == 'hours') { $duration = $emails->sending_duration * 3600; } else { if ($emails->sending_type == 'minutes') { $duration = $emails->sending_duration * 60; } else { if ($emails->sending_type == 'days') { $duration = $emails->sending_duration * 86400; } } } //duration is finished $cut_off_time = $each_cart->cart_abandon_time + $duration; $current_time = current_time('timestamp'); if ($current_time > $cut_off_time) { @($cart_url = WC_Cart::get_cart_url()); $url_to_click = esc_url_raw(add_query_arg(array('abandon_cart' => $each_cart->id, 'email_template' => $emails->id, 'guest' => 'yes'), $cart_url)); if (get_option('rac_cart_link_options') == '1') { $url_to_click = '<a style="color:' . get_option("rac_email_link_color") . '" href="' . $url_to_click . '">' . fp_get_wpml_text('rac_template_' . $emails->id . '_anchor_text', $each_cart->wpml_lang, $emails->anchor_text) . '</a>'; } elseif (get_option('rac_cart_link_options') == '2') { $url_to_click = $url_to_click; } else { $cart_Text = fp_get_wpml_text('rac_template_' . $emails->id . '_anchor_text', $each_cart->wpml_lang, $emails->anchor_text); $url_to_click = RecoverAbandonCart::rac_cart_link_button_mode($url_to_click, $cart_Text); } // $user = get_userdata($each_cart->user_id); NOT APPLICABLE // echo "<pre>"; // var_dump($each_cart->cart_details); // echo "</pre>"; @($order_object = maybe_unserialize($each_cart->cart_details)); // $order_objectinfo = maybe_unserialize($productifo->cart_details); $to = $order_object->billing_email; $user_lang = $each_cart->wpml_lang; $subject = fp_get_wpml_text('rac_template_' . $emails->id . '_subject', $each_cart->wpml_lang, $emails->subject); $firstname = $order_object->billing_first_name; $lastname = $order_object->billing_last_name; $message = fp_get_wpml_text('rac_template_' . $emails->id . '_message', $each_cart->wpml_lang, $emails->message); $message = str_replace('{rac.cartlink}', $url_to_click, $message); $subject = RecoverAbandonCart::shortcode_in_subject($firstname, $lastname, $subject); $message = str_replace('{rac.firstname}', $firstname, $message); $message = str_replace('{rac.lastname}', $lastname, $message); $message = str_replace('{rac.Productinfo}', $tablecheckproduct, $message); if (strpos($message, "{rac.coupon}")) { $coupon_code = FPRacCoupon::rac_create_coupon($order_object->billing_email, $each_cart->cart_abandon_time); $message = str_replace('{rac.coupon}', $coupon_code, $message); //replacing shortcode with coupon code } add_filter('woocommerce_email_footer_text', array('RecoverAbandonCart', 'rac_footer_email_customization')); $message = do_shortcode($message); //shortcode feature if (get_option('rac_email_use_temp_plain') != 'yes') { ob_start(); if (function_exists('wc_get_template')) { wc_get_template('emails/email-header.php', array('email_heading' => $subject)); echo $message; wc_get_template('emails/email-footer.php'); } else { woocommerce_get_template('emails/email-header.php', array('email_heading' => $subject)); echo $message; woocommerce_get_template('emails/email-footer.php'); } $woo_temp_msg = ob_get_clean(); } else { $woo_temp_msg = $message; } $headers = "MIME-Version: 1.0\r\n"; $headers .= "Content-Type: text/html; charset=UTF-8\r\n"; if ($emails->sender_opt == 'local') { $headers .= self::rac_formatted_from_address_local($emails->from_name, $emails->from_email); $headers .= "Reply-To: " . $emails->from_name . "<" . $emails->from_email . ">\r\n"; } else { $headers .= self::rac_formatted_from_address_woocommerce(); $headers .= "Reply-To: " . get_option('woocommerce_email_from_name') . "<" . get_option('woocommerce_email_from_address') . ">\r\n"; } if ($each_cart->sending_status == 'SEND') { //condition to check start/stop mail sending if ('wp_mail' == get_option('rac_trouble_mail')) { if (self::rac_send_wp_mail($to, $subject, $woo_temp_msg, $headers)) { // wp_mail($to, $subject, $message); $store_template_id = array($emails->id); $store_template_id = maybe_serialize($store_template_id); $wpdb->update($abandancart_table_name, array('mail_template_id' => $store_template_id), array('id' => $each_cart->id)); //add to mail log $table_name_logs = $wpdb->prefix . 'rac_email_logs'; $wpdb->insert($table_name_logs, array("email_id" => $to, "date_time" => $current_time, "rac_cart_id" => $each_cart->id, "template_used" => $emails->id)); FPRacCounter::rac_do_mail_count(); } } else { if (self::rac_send_mail($to, $subject, $woo_temp_msg, $headers)) { // wp_mail($to, $subject, $message); $store_template_id = array($emails->id); $store_template_id = maybe_serialize($store_template_id); $wpdb->update($abandancart_table_name, array('mail_template_id' => $store_template_id), array('id' => $each_cart->id)); //add to mail log $table_name_logs = $wpdb->prefix . 'rac_email_logs'; $wpdb->insert($table_name_logs, array("email_id" => $to, "date_time" => $current_time, "rac_cart_id" => $each_cart->id, "template_used" => $emails->id)); FPRacCounter::rac_do_mail_count(); } } } } elseif (!empty($each_cart->mail_template_id)) { $sent_mail_templates = maybe_unserialize($each_cart->mail_template_id); if (!in_array($emails->id, (array) $sent_mail_templates)) { if ($emails->sending_type == 'hours') { $duration = $emails->sending_duration * 3600; } else { if ($emails->sending_type == 'minutes') { $duration = $emails->sending_duration * 60; } else { if ($emails->sending_type == 'days') { $duration = $emails->sending_duration * 86400; } } } //duration is finished $cut_off_time = $each_cart->cart_abandon_time + $duration; $current_time = current_time('timestamp'); if ($current_time > $cut_off_time) { @($cart_url = WC_Cart::get_cart_url()); $url_to_click = esc_url_raw(add_query_arg(array('abandon_cart' => $each_cart->id, 'email_template' => $emails->id, 'guest' => 'yes'), $cart_url)); if (get_option('rac_cart_link_options') == '1') { $url_to_click = '<a style="color:' . get_option("rac_email_link_color") . '" href="' . $url_to_click . '">' . fp_get_wpml_text('rac_template_' . $emails->id . '_anchor_text', $each_cart->wpml_lang, $emails->anchor_text) . '</a>'; } elseif (get_option('rac_cart_link_options') == '2') { $url_to_click = $url_to_click; } else { $cart_Text = fp_get_wpml_text('rac_template_' . $emails->id . '_anchor_text', $each_cart->wpml_lang, $emails->anchor_text); $url_to_click = RecoverAbandonCart::rac_cart_link_button_mode($url_to_click, $cart_Text); } // $user = get_userdata($each_cart->user_id); NOT APPLICABLE $order_object = maybe_unserialize($each_cart->cart_details); $to = $order_object->billing_email; $user_lang = $each_cart->wpml_lang; $subject = fp_get_wpml_text('rac_template_' . $emails->id . '_subject', $each_cart->wpml_lang, $emails->subject); $firstname = $order_object->billing_first_name; $lastname = $order_object->billing_last_name; $message = fp_get_wpml_text('rac_template_' . $emails->id . '_message', $each_cart->wpml_lang, $emails->message); $message = str_replace('{rac.cartlink}', $url_to_click, $message); $subject = RecoverAbandonCart::shortcode_in_subject($firstname, $lastname, $subject); $message = str_replace('{rac.firstname}', $firstname, $message); $message = str_replace('{rac.lastname}', $lastname, $message); $message = str_replace('{rac.Productinfo}', $tablecheckproduct, $message); if (strpos($message, "{rac.coupon}")) { $coupon_code = FPRacCoupon::rac_create_coupon($order_object->billing_email, $each_cart->cart_abandon_time); $message = str_replace('{rac.coupon}', $coupon_code, $message); //replacing shortcode with coupon code } add_filter('woocommerce_email_footer_text', array('RecoverAbandonCart', 'rac_footer_email_customization')); $message = do_shortcode($message); //shortcode feature if (get_option('rac_email_use_temp_plain') != 'yes') { ob_start(); if (function_exists('wc_get_template')) { wc_get_template('emails/email-header.php', array('email_heading' => $subject)); echo $message; wc_get_template('emails/email-footer.php'); } else { woocommerce_get_template('emails/email-header.php', array('email_heading' => $subject)); echo $message; woocommerce_get_template('emails/email-footer.php'); } $woo_temp_msg = ob_get_clean(); } else { $woo_temp_msg = $message; } $headers = "MIME-Version: 1.0\r\n"; $headers .= "Content-Type: text/html; charset=UTF-8\r\n"; if ($emails->sender_opt == 'local') { $headers .= self::rac_formatted_from_address_local($emails->from_name, $emails->from_email); $headers .= "Reply-To: " . $emails->from_name . "<" . $emails->from_email . ">\r\n"; } else { $headers .= self::rac_formatted_from_address_woocommerce(); $headers .= "Reply-To: " . get_option('woocommerce_email_from_name') . "<" . get_option('woocommerce_email_from_address') . ">\r\n"; } if ($each_cart->sending_status == 'SEND') { //condition to check start/stop mail sending if ('wp_mail' == get_option('rac_trouble_mail')) { if (self::rac_send_wp_mail($to, $subject, $woo_temp_msg, $headers)) { // wp_mail($to, $subject, $message); $sent_mail_templates[] = $emails->id; $store_template_id = maybe_serialize($sent_mail_templates); $wpdb->update($abandancart_table_name, array('mail_template_id' => $store_template_id), array('id' => $each_cart->id)); //add to mail log $table_name_logs = $wpdb->prefix . 'rac_email_logs'; $wpdb->insert($table_name_logs, array("email_id" => $to, "date_time" => $current_time, "rac_cart_id" => $each_cart->id, "template_used" => $emails->id)); FPRacCounter::rac_do_mail_count(); } } else { if (self::rac_send_mail($to, $subject, $woo_temp_msg, $headers)) { // wp_mail($to, $subject, $message); $store_template_id = array($emails->id); $store_template_id = maybe_serialize($store_template_id); $wpdb->update($abandancart_table_name, array('mail_template_id' => $store_template_id), array('id' => $each_cart->id)); //add to mail log $table_name_logs = $wpdb->prefix . 'rac_email_logs'; $wpdb->insert($table_name_logs, array("email_id" => $to, "date_time" => $current_time, "rac_cart_id" => $each_cart->id, "template_used" => $emails->id)); FPRacCounter::rac_do_mail_count(); } } } } } } } } } } //FOR Guest Captured in chcekout page $abandon_carts = $wpdb->get_results("SELECT * FROM {$abandancart_table_name} WHERE cart_status='ABANDON' AND user_id='0' AND ip_address IS NOT NULL AND completed IS NULL"); //Selected only cart which are not completed foreach ($abandon_carts as $each_cart) { foreach ($email_templates as $emails) { $cart_array = maybe_unserialize($each_cart->cart_details); $tablecheckproduct = "<table style='width:100%;border:1px solid #eee;'><thead><tr>"; if (get_option('rac_hide_product_name_product_info_shortcode') != 'yes') { $tablecheckproduct .= "<th style='text-align:left;border:1px solid #eee;padding:12px' scope='col'>" . fp_get_wpml_text('rac_template_product_name', $each_cart->wpml_lang, get_option('rac_product_info_product_name')) . "</th>"; } if (get_option('rac_hide_product_image_product_info_shortcode') != 'yes') { $tablecheckproduct .= "<th style='text-align:left;border:1px solid #eee;padding:12px' scope='col'>" . fp_get_wpml_text('rac_template_product_image', $each_cart->wpml_lang, get_option('rac_product_info_product_image')) . "</th>"; } if (get_option('rac_hide_product_price_product_info_shortcode') != 'yes') { $tablecheckproduct .= "<th style='text-align:left;border:1px solid #eee;padding:12px' scope='col'>" . fp_get_wpml_text('rac_template_product_price', $each_cart->wpml_lang, get_option('rac_product_info_product_price')) . "</th>"; } $tablecheckproduct .= "</tr></thead><tbody>"; if (is_array($cart_array)) { /* $tablecheckproduct .= "It is from Guest Array"; $dump = print_r($cart_array, true); $tablecheckproduct .= "<pre>"; $tablecheckproduct .= $dump; $tablecheckproduct .= "</pre>"; */ foreach ($cart_array as $cart) { if (is_array($cart)) { if ((double) $woocommerce->version <= (double) '2.0.20') { $objectproduct = get_product($cart['product_id']); $objectproductvariable = get_product($cart['variation_id']); } else { $objectproduct = new WC_Product($cart['product_id']); $objectproductvariable = new WC_Product_Variable($cart['variation_id']); } $tablecheckproduct .= "<tr>"; if (get_option('rac_hide_product_name_product_info_shortcode') != 'yes') { $tablecheckproduct .= "<td style='text-align:left;vertical-align:middle;border:1px solid #eee;word-wrap:break-word;padding:12px'>" . get_the_title($cart['product_id']) . "</td>"; } if (get_option('rac_hide_product_image_product_info_shortcode') != 'yes') { $tablecheckproduct .= "<td style='text-align:left;vertical-align:middle;border:1px solid #eee;word-wrap:break-word;padding:12px'>" . get_the_post_thumbnail($cart['product_id'], array(90, 90)) . "</td>"; } if (get_option('rac_hide_product_price_product_info_shortcode') != 'yes') { $tablecheckproduct .= "<td style='text-align:left;vertical-align:middle;border:1px solid #eee;word-wrap:break-word;padding:12px'>" . self::get_rac_formatprice($cart['variation_id'] == '' ? $objectproduct->get_price() : $objectproductvariable->get_price()) . "</td>"; } $tablecheckproduct .= "</tr>"; } } } elseif (is_object($cart_array)) { /* $tablecheckproduct .= "It is from Guest1 Object"; $dump = print_r($cart_array, true); $tablecheckproduct .= $dump; */ $order = new WC_Order($cart_array->id); // if ($order->user_id != '') { foreach ($order->get_items() as $products) { if ((double) $woocommerce->version <= (double) '2.0.20') { $objectproduct = get_product($products['product_id']); $objectproductvariable = get_product($products['variation_id']); } else { $objectproduct = new WC_Product($products['product_id']); $objectproductvariable = new WC_Product_Variable($products['variation_id']); } $tablecheckproduct .= "<tr>"; if (get_option('rac_hide_product_name_product_info_shortcode') != 'yes') { $tablecheckproduct .= "<td style='text-align:left;vertical-align:middle;border:1px solid #eee;word-wrap:break-word;padding:12px'>" . get_the_title($products['product_id']) . "</td>"; } if (get_option('rac_hide_product_image_product_info_shortcode') != 'yes') { $tablecheckproduct .= "<td style='text-align:left;vertical-align:middle;border:1px solid #eee;word-wrap:break-word;padding:12px'>" . get_the_post_thumbnail($products['product_id'], array(90, 90)) . "</td>"; } if (get_option('rac_hide_product_price_product_info_shortcode') != 'yes') { $tablecheckproduct .= "<td style='text-align:left;vertical-align:middle;border:1px solid #eee;word-wrap:break-word;padding:12px'>" . self::get_rac_formatprice($products['variation_id'] == '' ? $objectproduct->get_price() : $objectproductvariable->get_price()) . "</td>"; } $tablecheckproduct .= "</tr>"; } // } } $tablecheckproduct .= "</table>"; if ($emails->status == "ACTIVE") { if (empty($each_cart->mail_template_id)) { // IF EMPTY IT IS NOT SENT FOR ANY SINGLE TEMPLATE if ($emails->sending_type == 'hours') { $duration = $emails->sending_duration * 3600; } else { if ($emails->sending_type == 'minutes') { $duration = $emails->sending_duration * 60; } else { if ($emails->sending_type == 'days') { $duration = $emails->sending_duration * 86400; } } } //duration is finished $cut_off_time = $each_cart->cart_abandon_time + $duration; $current_time = current_time('timestamp'); if ($current_time > $cut_off_time) { @($cart_url = WC_Cart::get_cart_url()); $url_to_click = esc_url_raw(add_query_arg(array('abandon_cart' => $each_cart->id, 'email_template' => $emails->id, 'guest' => 'yes', 'checkout' => 'yes'), $cart_url)); if (get_option('rac_cart_link_options') == '1') { $url_to_click = '<a style="color:' . get_option("rac_email_link_color") . '" href="' . $url_to_click . '">' . fp_get_wpml_text('rac_template_' . $emails->id . '_anchor_text', $each_cart->wpml_lang, $emails->anchor_text) . '</a>'; } elseif (get_option('rac_cart_link_options') == '2') { $url_to_click = $url_to_click; } else { $cart_Text = fp_get_wpml_text('rac_template_' . $emails->id . '_anchor_text', $each_cart->wpml_lang, $emails->anchor_text); $url_to_click = RecoverAbandonCart::rac_cart_link_button_mode($url_to_click, $cart_Text); } // $user = get_userdata($each_cart->user_id); NOT APPLICABLE $order_object = maybe_unserialize($each_cart->cart_details); $to = $order_object['visitor_mail']; $user_lang = $each_cart->wpml_lang; $subject = fp_get_wpml_text('rac_template_' . $emails->id . '_subject', $each_cart->wpml_lang, $emails->subject); $firstname = $order_object['first_name']; $lastname = $order_object['last_name']; $message = fp_get_wpml_text('rac_template_' . $emails->id . '_message', $each_cart->wpml_lang, $emails->message); $message = str_replace('{rac.cartlink}', $url_to_click, $message); $subject = RecoverAbandonCart::shortcode_in_subject($firstname, $lastname, $subject); $message = str_replace('{rac.firstname}', $firstname, $message); $message = str_replace('{rac.lastname}', $lastname, $message); $message = str_replace('{rac.Productinfo}', $tablecheckproduct, $message); if (strpos($message, "{rac.coupon}")) { $coupon_code = FPRacCoupon::rac_create_coupon($order_object['visitor_mail'], $each_cart->cart_abandon_time); $message = str_replace('{rac.coupon}', $coupon_code, $message); //replacing shortcode with coupon code } add_filter('woocommerce_email_footer_text', array('RecoverAbandonCart', 'rac_footer_email_customization')); $message = do_shortcode($message); //shortcode feature if (get_option('rac_email_use_temp_plain') != 'yes') { ob_start(); if (function_exists('wc_get_template')) { wc_get_template('emails/email-header.php', array('email_heading' => $subject)); echo $message; wc_get_template('emails/email-footer.php'); } else { woocommerce_get_template('emails/email-header.php', array('email_heading' => $subject)); echo $message; woocommerce_get_template('emails/email-footer.php'); } $woo_temp_msg = ob_get_clean(); } else { $woo_temp_msg = $message; } $headers = "MIME-Version: 1.0\r\n"; $headers .= "Content-Type: text/html; charset=UTF-8\r\n"; if ($emails->sender_opt == 'local') { $headers .= self::rac_formatted_from_address_local($emails->from_name, $emails->from_email); $headers .= "Reply-To: " . $emails->from_name . "<" . $emails->from_email . ">\r\n"; } else { $headers .= self::rac_formatted_from_address_woocommerce(); $headers .= "Reply-To: " . get_option('woocommerce_email_from_name') . "<" . get_option('woocommerce_email_from_address') . ">\r\n"; } if ($each_cart->sending_status == 'SEND') { //condition to check start/stop mail sending if ('wp_mail' == get_option('rac_trouble_mail')) { // var_dump($to,$subject,$woo_temp_msg,$headers); if (self::rac_send_wp_mail($to, $subject, $woo_temp_msg, $headers)) { // wp_mail($to, $subject, $message); $store_template_id = array($emails->id); $store_template_id = maybe_serialize($store_template_id); $wpdb->update($abandancart_table_name, array('mail_template_id' => $store_template_id), array('id' => $each_cart->id)); //add to mail log $table_name_logs = $wpdb->prefix . 'rac_email_logs'; $wpdb->insert($table_name_logs, array("email_id" => $to, "date_time" => $current_time, "rac_cart_id" => $each_cart->id, "template_used" => $emails->id)); FPRacCounter::rac_do_mail_count(); } } else { if (self::rac_send_mail($to, $subject, $woo_temp_msg, $headers)) { // wp_mail($to, $subject, $message); $store_template_id = array($emails->id); $store_template_id = maybe_serialize($store_template_id); $wpdb->update($abandancart_table_name, array('mail_template_id' => $store_template_id), array('id' => $each_cart->id)); //add to mail log $table_name_logs = $wpdb->prefix . 'rac_email_logs'; $wpdb->insert($table_name_logs, array("email_id" => $to, "date_time" => $current_time, "rac_cart_id" => $each_cart->id, "template_used" => $emails->id)); FPRacCounter::rac_do_mail_count(); } } } } } elseif (!empty($each_cart->mail_template_id)) { $sent_mail_templates = maybe_unserialize($each_cart->mail_template_id); if (!in_array($emails->id, (array) $sent_mail_templates)) { if ($emails->sending_type == 'hours') { $duration = $emails->sending_duration * 3600; } else { if ($emails->sending_type == 'minutes') { $duration = $emails->sending_duration * 60; } else { if ($emails->sending_type == 'days') { $duration = $emails->sending_duration * 86400; } } } //duration is finished $cut_off_time = $each_cart->cart_abandon_time + $duration; $current_time = current_time('timestamp'); if ($current_time > $cut_off_time) { @($cart_url = WC_Cart::get_cart_url()); $url_to_click = esc_url_raw(add_query_arg(array('abandon_cart' => $each_cart->id, 'email_template' => $emails->id, 'guest' => 'yes', 'checkout' => 'yes'), $cart_url)); if (get_option('rac_cart_link_options') == '1') { $url_to_click = '<a style="color:' . get_option("rac_email_link_color") . '" href="' . $url_to_click . '">' . fp_get_wpml_text('rac_template_' . $emails->id . '_anchor_text', $each_cart->wpml_lang, $emails->anchor_text) . '</a>'; } elseif (get_option('rac_cart_link_options') == '2') { $url_to_click = $url_to_click; } else { $cart_Text = fp_get_wpml_text('rac_template_' . $emails->id . '_anchor_text', $each_cart->wpml_lang, $emails->anchor_text); $url_to_click = RecoverAbandonCart::rac_cart_link_button_mode($url_to_click, $cart_Text); } // $user = get_userdata($each_cart->user_id); NOT APPLICABLE $order_object = maybe_unserialize($each_cart->cart_details); $to = $order_object['visitor_mail']; $user_lang = $each_cart->wpml_lang; $subject = fp_get_wpml_text('rac_template_' . $emails->id . '_subject', $each_cart->wpml_lang, $emails->subject); $firstname = $order_object['first_name']; $lastname = $order_object['last_name']; $message = fp_get_wpml_text('rac_template_' . $emails->id . '_message', $each_cart->wpml_lang, $emails->message); $message = str_replace('{rac.cartlink}', $url_to_click, $message); $subject = RecoverAbandonCart::shortcode_in_subject($firstname, $lastname, $subject); $message = str_replace('{rac.firstname}', $firstname, $message); $message = str_replace('{rac.lastname}', $lastname, $message); $message = str_replace('{rac.Productinfo}', $tablecheckproduct, $message); if (strpos($message, "{rac.coupon}")) { $coupon_code = FPRacCoupon::rac_create_coupon($order_object['visitor_mail'], $each_cart->cart_abandon_time); $message = str_replace('{rac.coupon}', $coupon_code, $message); //replacing shortcode with coupon code } add_filter('woocommerce_email_footer_text', array('RecoverAbandonCart', 'rac_footer_email_customization')); $message = do_shortcode($message); //shortcode feature if (get_option('rac_email_use_temp_plain') != 'yes') { ob_start(); if (function_exists('wc_get_template')) { wc_get_template('emails/email-header.php', array('email_heading' => $subject)); echo $message; wc_get_template('emails/email-footer.php'); } else { woocommerce_get_template('emails/email-header.php', array('email_heading' => $subject)); echo $message; woocommerce_get_template('emails/email-footer.php'); } $woo_temp_msg = ob_get_clean(); } else { $woo_temp_msg = $message; } $headers = "MIME-Version: 1.0\r\n"; $headers .= "Content-Type: text/html; charset=UTF-8\r\n"; if ($emails->sender_opt == 'local') { $headers .= self::rac_formatted_from_address_local($emails->from_name, $emails->from_email); $headers .= "Reply-To: " . $emails->from_name . "<" . $emails->from_email . ">\r\n"; } else { $headers .= self::rac_formatted_from_address_woocommerce(); $headers .= "Reply-To: " . get_option('woocommerce_email_from_name') . "<" . get_option('woocommerce_email_from_address') . ">\r\n"; } if ($each_cart->sending_status == 'SEND') { //condition to check start/stop mail sending if ('wp_mail' == get_option('rac_trouble_mail')) { if (self::rac_send_wp_mail($to, $subject, $woo_temp_msg, $headers)) { // wp_mail($to, $subject, $message); $sent_mail_templates[] = $emails->id; $store_template_id = maybe_serialize($sent_mail_templates); $wpdb->update($abandancart_table_name, array('mail_template_id' => $store_template_id), array('id' => $each_cart->id)); //add to mail log $table_name_logs = $wpdb->prefix . 'rac_email_logs'; $wpdb->insert($table_name_logs, array("email_id" => $to, "date_time" => $current_time, "rac_cart_id" => $each_cart->id, "template_used" => $emails->id)); FPRacCounter::rac_do_mail_count(); } } else { if (self::rac_send_mail($to, $subject, $woo_temp_msg, $headers)) { // wp_mail($to, $subject, $message); $sent_mail_templates[] = $emails->id; $store_template_id = maybe_serialize($sent_mail_templates); $wpdb->update($abandancart_table_name, array('mail_template_id' => $store_template_id), array('id' => $each_cart->id)); //add to mail log $table_name_logs = $wpdb->prefix . 'rac_email_logs'; $wpdb->insert($table_name_logs, array("email_id" => $to, "date_time" => $current_time, "rac_cart_id" => $each_cart->id, "template_used" => $emails->id)); FPRacCounter::rac_do_mail_count(); } } } } } } } } } } // FOR ORDER UPDATED FROM OLD $abandon_carts = $wpdb->get_results("SELECT * FROM {$abandancart_table_name} WHERE cart_status='ABANDON' AND user_id='old_order' AND ip_address IS NULL AND completed IS NULL"); //Selected only cart which are not completed foreach ($abandon_carts as $each_cart) { foreach ($email_templates as $emails) { $cart_array = maybe_unserialize($each_cart->cart_details); $tablecheckproduct = "<table style='width:100%;border:1px solid #eee;'><thead><tr>"; if (get_option('rac_hide_product_name_product_info_shortcode') != 'yes') { $tablecheckproduct .= "<th style='text-align:left;border:1px solid #eee;padding:12px' scope='col'>" . fp_get_wpml_text('rac_template_product_name', $each_cart->wpml_lang, get_option('rac_product_info_product_name')) . "</th>"; } if (get_option('rac_hide_product_image_product_info_shortcode') != 'yes') { $tablecheckproduct .= "<th style='text-align:left;border:1px solid #eee;padding:12px' scope='col'>" . fp_get_wpml_text('rac_template_product_image', $each_cart->wpml_lang, get_option('rac_product_info_product_image')) . "</th>"; } if (get_option('rac_hide_product_price_product_info_shortcode') != 'yes') { $tablecheckproduct .= "<th style='text-align:left;border:1px solid #eee;padding:12px' scope='col'>" . fp_get_wpml_text('rac_template_product_price', $each_cart->wpml_lang, get_option('rac_product_info_product_price')) . "</th>"; } $tablecheckproduct .= "</tr></thead><tbody>"; if (is_object($cart_array)) { if (get_option('rac_email_use_members') == 'yes') { /* $tablecheckproduct .= "It is from Member Object"; $dump = print_r($cart_array, true); $tablecheckproduct .= $dump; */ $order = new WC_Order($cart_array->id); if ($order->user_id != '') { foreach ($order->get_items() as $products) { if ((double) $woocommerce->version <= (double) '2.0.20') { $objectproduct = get_product($products['product_id']); $objectproductvariable = get_product($products['variation_id']); } else { $objectproduct = new WC_Product($products['product_id']); $objectproductvariable = new WC_Product_Variable($products['variation_id']); } $tablecheckproduct .= "<tr>"; if (get_option('rac_hide_product_name_product_info_shortcode') != 'yes') { $tablecheckproduct .= "<td style='text-align:left;vertical-align:middle;border:1px solid #eee;word-wrap:break-word;padding:12px'>" . get_the_title($products['product_id']) . "</td>"; } if (get_option('rac_hide_product_image_product_info_shortcode') != 'yes') { $tablecheckproduct .= "<td style='text-align:left;vertical-align:middle;border:1px solid #eee;word-wrap:break-word;padding:12px'>" . get_the_post_thumbnail($products['product_id'], array(90, 90)) . "</td>"; } if (get_option('rac_hide_product_price_product_info_shortcode') != 'yes') { $tablecheckproduct .= "<td style='text-align:left;vertical-align:middle;border:1px solid #eee;word-wrap:break-word;padding:12px'>" . self::get_rac_formatprice($products['variation_id'] == '' ? $objectproduct->get_price() : $objectproductvariable->get_price()) . "</td>"; } $tablecheckproduct .= "</tr>"; } } //mail if ($emails->status == "ACTIVE") { if (empty($each_cart->mail_template_id)) { // IF EMPTY IT IS NOT SENT FOR ANY SINGLE TEMPLATE if ($emails->sending_type == 'hours') { $duration = $emails->sending_duration * 3600; } else { if ($emails->sending_type == 'minutes') { $duration = $emails->sending_duration * 60; } else { if ($emails->sending_type == 'days') { $duration = $emails->sending_duration * 86400; } } } //duration is finished $cut_off_time = $each_cart->cart_abandon_time + $duration; $current_time = current_time('timestamp'); if ($current_time > $cut_off_time) { @($cart_url = WC_Cart::get_cart_url()); $url_to_click = esc_url_raw(add_query_arg(array('abandon_cart' => $each_cart->id, 'email_template' => $emails->id, 'old_order' => 'yes'), $cart_url)); if (get_option('rac_cart_link_options') == '1') { $url_to_click = '<a style="color:' . get_option("rac_email_link_color") . '" href="' . $url_to_click . '">' . fp_get_wpml_text('rac_template_' . $emails->id . '_anchor_text', $each_cart->wpml_lang, $emails->anchor_text) . '</a>'; } elseif (get_option('rac_cart_link_options') == '2') { $url_to_click = $url_to_click; } else { $cart_Text = fp_get_wpml_text('rac_template_' . $emails->id . '_anchor_text', $each_cart->wpml_lang, $emails->anchor_text); $url_to_click = RecoverAbandonCart::rac_cart_link_button_mode($url_to_click, $cart_Text); } // $user = get_userdata($each_cart->user_id); NOT APPLICABLE $order_object = maybe_unserialize($each_cart->cart_details); $to = $order_object->billing_email; $user_lang = $each_cart->wpml_lang; $subject = fp_get_wpml_text('rac_template_' . $emails->id . '_subject', $each_cart->wpml_lang, $emails->subject); $firstname = $order_object->billing_first_name; $lastname = $order_object->billing_last_name; $message = fp_get_wpml_text('rac_template_' . $emails->id . '_message', $each_cart->wpml_lang, $emails->message); $message = str_replace('{rac.cartlink}', $url_to_click, $message); $subject = RecoverAbandonCart::shortcode_in_subject($firstname, $lastname, $subject); $message = str_replace('{rac.firstname}', $firstname, $message); $message = str_replace('{rac.lastname}', $lastname, $message); $message = str_replace('{rac.Productinfo}', $tablecheckproduct, $message); if (strpos($message, "{rac.coupon}")) { $coupon_code = FPRacCoupon::rac_create_coupon($order_object->billing_email, $each_cart->cart_abandon_time); $message = str_replace('{rac.coupon}', $coupon_code, $message); //replacing shortcode with coupon code } add_filter('woocommerce_email_footer_text', array('RecoverAbandonCart', 'rac_footer_email_customization')); $message = do_shortcode($message); //shortcode feature if (get_option('rac_email_use_temp_plain') != 'yes') { ob_start(); if (function_exists('wc_get_template')) { wc_get_template('emails/email-header.php', array('email_heading' => $subject)); echo $message; wc_get_template('emails/email-footer.php'); } else { woocommerce_get_template('emails/email-header.php', array('email_heading' => $subject)); echo $message; woocommerce_get_template('emails/email-footer.php'); } $woo_temp_msg = ob_get_clean(); } else { $woo_temp_msg = $message; } $headers = "MIME-Version: 1.0\r\n"; $headers .= "Content-Type: text/html; charset=UTF-8\r\n"; if ($emails->sender_opt == 'local') { $headers .= self::rac_formatted_from_address_local($emails->from_name, $emails->from_email); $headers .= "Reply-To: " . $emails->from_name . "<" . $emails->from_email . ">\r\n"; } else { $headers .= self::rac_formatted_from_address_woocommerce(); $headers .= "Reply-To: " . get_option('woocommerce_email_from_name') . "<" . get_option('woocommerce_email_from_address') . ">\r\n"; } if ($each_cart->sending_status == 'SEND') { //condition to check start/stop mail sending if ('wp_mail' == get_option('rac_trouble_mail')) { if (self::rac_send_wp_mail($to, $subject, $woo_temp_msg, $headers)) { // wp_mail($to, $subject, $message); $store_template_id = array($emails->id); $store_template_id = maybe_serialize($store_template_id); $wpdb->update($abandancart_table_name, array('mail_template_id' => $store_template_id), array('id' => $each_cart->id)); //add to mail log $table_name_logs = $wpdb->prefix . 'rac_email_logs'; $wpdb->insert($table_name_logs, array("email_id" => $to, "date_time" => $current_time, "rac_cart_id" => $each_cart->id, "template_used" => $emails->id)); FPRacCounter::rac_do_mail_count(); } } else { if (self::rac_send_mail($to, $subject, $woo_temp_msg, $headers)) { // wp_mail($to, $subject, $message); $store_template_id = array($emails->id); $store_template_id = maybe_serialize($store_template_id); $wpdb->update($abandancart_table_name, array('mail_template_id' => $store_template_id), array('id' => $each_cart->id)); //add to mail log $table_name_logs = $wpdb->prefix . 'rac_email_logs'; $wpdb->insert($table_name_logs, array("email_id" => $to, "date_time" => $current_time, "rac_cart_id" => $each_cart->id, "template_used" => $emails->id)); FPRacCounter::rac_do_mail_count(); } } } } } elseif (!empty($each_cart->mail_template_id)) { $sent_mail_templates = maybe_unserialize($each_cart->mail_template_id); if (!in_array($emails->id, (array) $sent_mail_templates)) { if ($emails->sending_type == 'hours') { $duration = $emails->sending_duration * 3600; } else { if ($emails->sending_type == 'minutes') { $duration = $emails->sending_duration * 60; } else { if ($emails->sending_type == 'days') { $duration = $emails->sending_duration * 86400; } } } //duration is finished $cut_off_time = $each_cart->cart_abandon_time + $duration; $current_time = current_time('timestamp'); if ($current_time > $cut_off_time) { @($cart_url = WC_Cart::get_cart_url()); $url_to_click = esc_url_raw(add_query_arg(array('abandon_cart' => $each_cart->id, 'email_template' => $emails->id, 'old_order' => 'yes'), $cart_url)); if (get_option('rac_cart_link_options') == '1') { $url_to_click = '<a style="color:' . get_option("rac_email_link_color") . '" href="' . $url_to_click . '">' . fp_get_wpml_text('rac_template_' . $emails->id . '_anchor_text', $each_cart->wpml_lang, $emails->anchor_text) . '</a>'; } elseif (get_option('rac_cart_link_options') == '2') { $url_to_click = $url_to_click; } else { $cart_Text = fp_get_wpml_text('rac_template_' . $emails->id . '_anchor_text', $each_cart->wpml_lang, $emails->anchor_text); $url_to_click = RecoverAbandonCart::rac_cart_link_button_mode($url_to_click, $cart_Text); } // $user = get_userdata($each_cart->user_id); NOT APPLICABLE $order_object = maybe_unserialize($each_cart->cart_details); $to = $order_object->billing_email; $user_lang = $each_cart->wpml_lang; $subject = fp_get_wpml_text('rac_template_' . $emails->id . '_subject', $each_cart->wpml_lang, $emails->subject); $firstname = $order_object->billing_first_name; $lastname = $order_object->billing_last_name; $message = fp_get_wpml_text('rac_template_' . $emails->id . '_message', $each_cart->wpml_lang, $emails->message); $message = str_replace('{rac.cartlink}', $url_to_click, $message); $subject = RecoverAbandonCart::shortcode_in_subject($firstname, $lastname, $subject); $message = str_replace('{rac.firstname}', $firstname, $message); $message = str_replace('{rac.lastname}', $lastname, $message); $message = str_replace('{rac.Productinfo}', $tablecheckproduct, $message); if (strpos($message, "{rac.coupon}")) { $coupon_code = FPRacCoupon::rac_create_coupon($order_object->billing_email, $each_cart->cart_abandon_time); $message = str_replace('{rac.coupon}', $coupon_code, $message); //replacing shortcode with coupon code } add_filter('woocommerce_email_footer_text', array('RecoverAbandonCart', 'rac_footer_email_customization')); $message = do_shortcode($message); //shortcode feature if (get_option('rac_email_use_temp_plain') != 'yes') { ob_start(); if (function_exists('wc_get_template')) { wc_get_template('emails/email-header.php', array('email_heading' => $subject)); echo $message; wc_get_template('emails/email-footer.php'); } else { woocommerce_get_template('emails/email-header.php', array('email_heading' => $subject)); echo $message; woocommerce_get_template('emails/email-footer.php'); } $woo_temp_msg = ob_get_clean(); } else { $woo_temp_msg = $message; } $headers = "MIME-Version: 1.0\r\n"; $headers .= "Content-Type: text/html; charset=UTF-8\r\n"; if ($emails->sender_opt == 'local') { $headers .= self::rac_formatted_from_address_local($emails->from_name, $emails->from_email); $headers .= "Reply-To: " . $emails->from_name . " <" . $emails->from_email . ">\r\n"; } else { $headers .= self::rac_formatted_from_address_woocommerce(); $headers .= "Reply-To: " . get_option('woocommerce_email_from_name') . "<" . get_option('woocommerce_email_from_address') . ">\r\n"; } if ($each_cart->sending_status == 'SEND') { //condition to check start/stop mail sending if ('wp_mail' == get_option('rac_trouble_mail')) { if (self::rac_send_wp_mail($to, $subject, $woo_temp_msg, $headers)) { // wp_mail($to, $subject, $message); $sent_mail_templates[] = $emails->id; $store_template_id = maybe_serialize($sent_mail_templates); $wpdb->update($abandancart_table_name, array('mail_template_id' => $store_template_id), array('id' => $each_cart->id)); //add to mail log $table_name_logs = $wpdb->prefix . 'rac_email_logs'; $wpdb->insert($table_name_logs, array("email_id" => $to, "date_time" => $current_time, "rac_cart_id" => $each_cart->id, "template_used" => $emails->id)); FPRacCounter::rac_do_mail_count(); } } else { if (self::rac_send_mail($to, $subject, $woo_temp_msg, $headers)) { // wp_mail($to, $subject, $message); $sent_mail_templates[] = $emails->id; $store_template_id = maybe_serialize($sent_mail_templates); $wpdb->update($abandancart_table_name, array('mail_template_id' => $store_template_id), array('id' => $each_cart->id)); //add to mail log $table_name_logs = $wpdb->prefix . 'rac_email_logs'; $wpdb->insert($table_name_logs, array("email_id" => $to, "date_time" => $current_time, "rac_cart_id" => $each_cart->id, "template_used" => $emails->id)); FPRacCounter::rac_do_mail_count(); } } } } } } } } if (get_option('rac_email_use_guests') == 'yes') { /* $tablecheckproduct .= "It is from Guest2 Object"; $dump = print_r($cart_array, true); $tablecheckproduct .= $dump; */ // if ($order->user_id == '') { foreach ($order->get_items() as $products) { if ((double) $woocommerce->version <= (double) '2.0.20') { $objectproduct = get_product($products['product_id']); $objectproductvariable = get_product($products['variation_id']); } else { $objectproduct = new WC_Product($products['product_id']); $objectproductvariable = new WC_Product_Variable($products['variation_id']); } $tablecheckproduct .= "<tr>"; if (get_option('rac_hide_product_name_product_info_shortcode') != 'yes') { $tablecheckproduct .= "<td style='text-align:left;vertical-align:middle;border:1px solid #eee;word-wrap:break-word;padding:12px'>" . get_the_title($products['product_id']) . "</td>"; } if (get_option('rac_hide_product_image_product_info_shortcode') != 'yes') { $tablecheckproduct .= "<td style='text-align:left;vertical-align:middle;border:1px solid #eee;word-wrap:break-word;padding:12px'>" . get_the_post_thumbnail($products['product_id'], array(90, 90)) . "</td>"; } if (get_option('rac_hide_product_price_product_info_shortcode') != 'yes') { $tablecheckproduct .= "<td style='text-align:left;vertical-align:middle;border:1px solid #eee;word-wrap:break-word;padding:12px'>" . self::get_rac_formatprice($products['variation_id'] == '' ? $objectproduct->get_price() : $objectproductvariable->get_price()) . "</td>"; } $tablecheckproduct .= "</tr>"; } // } $tablecheckproduct .= "</table>"; //guest mail if ($emails->status == "ACTIVE") { if (empty($each_cart->mail_template_id)) { // IF EMPTY IT IS NOT SENT FOR ANY SINGLE TEMPLATE if ($emails->sending_type == 'hours') { $duration = $emails->sending_duration * 3600; } else { if ($emails->sending_type == 'minutes') { $duration = $emails->sending_duration * 60; } else { if ($emails->sending_type == 'days') { $duration = $emails->sending_duration * 86400; } } } //duration is finished $cut_off_time = $each_cart->cart_abandon_time + $duration; $current_time = current_time('timestamp'); if ($current_time > $cut_off_time) { @($cart_url = WC_Cart::get_cart_url()); $url_to_click = esc_url_raw(add_query_arg(array('abandon_cart' => $each_cart->id, 'email_template' => $emails->id, 'old_order' => 'yes'), $cart_url)); if (get_option('rac_cart_link_options') == '1') { $url_to_click = '<a style="color:' . get_option("rac_email_link_color") . '" href="' . $url_to_click . '">' . fp_get_wpml_text('rac_template_' . $emails->id . '_anchor_text', $each_cart->wpml_lang, $emails->anchor_text) . '</a>'; } elseif (get_option('rac_cart_link_options') == '2') { $url_to_click = $url_to_click; } else { $cart_Text = fp_get_wpml_text('rac_template_' . $emails->id . '_anchor_text', $each_cart->wpml_lang, $emails->anchor_text); $url_to_click = RecoverAbandonCart::rac_cart_link_button_mode($url_to_click, $cart_Text); } // $user = get_userdata($each_cart->user_id); NOT APPLICABLE $order_object = maybe_unserialize($each_cart->cart_details); $to = $order_object->billing_email; $user_lang = $each_cart->wpml_lang; $subject = fp_get_wpml_text('rac_template_' . $emails->id . '_subject', $each_cart->wpml_lang, $emails->subject); $firstname = $order_object->billing_first_name; $lastname = $order_object->billing_last_name; $message = fp_get_wpml_text('rac_template_' . $emails->id . '_message', $each_cart->wpml_lang, $emails->message); $message = str_replace('{rac.cartlink}', $url_to_click, $message); $subject = RecoverAbandonCart::shortcode_in_subject($firstname, $lastname, $subject); $message = str_replace('{rac.firstname}', $firstname, $message); $message = str_replace('{rac.lastname}', $lastname, $message); $message = str_replace('{rac.Productinfo}', $tablecheckproduct, $message); if (strpos($message, "{rac.coupon}")) { $coupon_code = FPRacCoupon::rac_create_coupon($order_object->billing_email, $each_cart->cart_abandon_time); $message = str_replace('{rac.coupon}', $coupon_code, $message); //replacing shortcode with coupon code } add_filter('woocommerce_email_footer_text', array('RecoverAbandonCart', 'rac_footer_email_customization')); $message = do_shortcode($message); //shortcode feature if (get_option('rac_email_use_temp_plain') != 'yes') { ob_start(); if (function_exists('wc_get_template')) { wc_get_template('emails/email-header.php', array('email_heading' => $subject)); echo $message; wc_get_template('emails/email-footer.php'); } else { woocommerce_get_template('emails/email-header.php', array('email_heading' => $subject)); echo $message; woocommerce_get_template('emails/email-footer.php'); } $woo_temp_msg = ob_get_clean(); } else { $woo_temp_msg = $message; } $headers = "MIME-Version: 1.0\r\n"; $headers .= "Content-Type: text/html; charset=UTF-8\r\n"; if ($emails->sender_opt == 'local') { $headers .= self::rac_formatted_from_address_local($emails->from_name, $emails->from_email); $headers .= "Reply-To: " . $emails->from_name . "<" . $emails->from_email . ">\r\n"; } else { $headers .= self::rac_formatted_from_address_woocommerce(); $headers .= "Reply-To: " . get_option('woocommerce_email_from_name') . "<" . get_option('woocommerce_email_from_address') . ">\r\n"; } if ($each_cart->sending_status == 'SEND') { //condition to check start/stop mail sending if ('wp_mail' == get_option('rac_trouble_mail')) { if (self::rac_send_wp_mail($to, $subject, $woo_temp_msg, $headers)) { // wp_mail($to, $subject, $message); $store_template_id = array($emails->id); $store_template_id = maybe_serialize($store_template_id); $wpdb->update($abandancart_table_name, array('mail_template_id' => $store_template_id), array('id' => $each_cart->id)); //add to mail log $table_name_logs = $wpdb->prefix . 'rac_email_logs'; $wpdb->insert($table_name_logs, array("email_id" => $to, "date_time" => $current_time, "rac_cart_id" => $each_cart->id, "template_used" => $emails->id)); FPRacCounter::rac_do_mail_count(); } } else { if (self::rac_send_mail($to, $subject, $woo_temp_msg, $headers)) { // wp_mail($to, $subject, $message); $store_template_id = array($emails->id); $store_template_id = maybe_serialize($store_template_id); $wpdb->update($abandancart_table_name, array('mail_template_id' => $store_template_id), array('id' => $each_cart->id)); //add to mail log $table_name_logs = $wpdb->prefix . 'rac_email_logs'; $wpdb->insert($table_name_logs, array("email_id" => $to, "date_time" => $current_time, "rac_cart_id" => $each_cart->id, "template_used" => $emails->id)); FPRacCounter::rac_do_mail_count(); } } } } } elseif (!empty($each_cart->mail_template_id)) { $sent_mail_templates = maybe_unserialize($each_cart->mail_template_id); if (!in_array($emails->id, (array) $sent_mail_templates)) { if ($emails->sending_type == 'hours') { $duration = $emails->sending_duration * 3600; } else { if ($emails->sending_type == 'minutes') { $duration = $emails->sending_duration * 60; } else { if ($emails->sending_type == 'days') { $duration = $emails->sending_duration * 86400; } } } //duration is finished $cut_off_time = $each_cart->cart_abandon_time + $duration; $current_time = current_time('timestamp'); if ($current_time > $cut_off_time) { @($cart_url = WC_Cart::get_cart_url()); $url_to_click = esc_url_raw(add_query_arg(array('abandon_cart' => $each_cart->id, 'email_template' => $emails->id, 'old_order' => 'yes'), $cart_url)); if (get_option('rac_cart_link_options') == '1') { $url_to_click = '<a style="color:' . get_option("rac_email_link_color") . '" href="' . $url_to_click . '">' . fp_get_wpml_text('rac_template_' . $emails->id . '_anchor_text', $each_cart->wpml_lang, $emails->anchor_text) . '</a>'; } elseif (get_option('rac_cart_link_options') == '2') { $url_to_click = $url_to_click; } else { $cart_Text = fp_get_wpml_text('rac_template_' . $emails->id . '_anchor_text', $each_cart->wpml_lang, $emails->anchor_text); $url_to_click = RecoverAbandonCart::rac_cart_link_button_mode($url_to_click, $cart_Text); } // $user = get_userdata($each_cart->user_id); NOT APPLICABLE $order_object = maybe_unserialize($each_cart->cart_details); $to = $order_object->billing_email; $user_lang = $each_cart->wpml_lang; $subject = fp_get_wpml_text('rac_template_' . $emails->id . '_subject', $each_cart->wpml_lang, $emails->subject); $firstname = $order_object->billing_first_name; $lastname = $order_object->billing_last_name; $message = fp_get_wpml_text('rac_template_' . $emails->id . '_message', $each_cart->wpml_lang, $emails->message); $message = str_replace('{rac.cartlink}', $url_to_click, $message); $subject = RecoverAbandonCart::shortcode_in_subject($firstname, $lastname, $subject); $message = str_replace('{rac.firstname}', $firstname, $message); $message = str_replace('{rac.lastname}', $lastname, $message); $message = str_replace('{rac.Productinfo}', $tablecheckproduct, $message); if (strpos($message, "{rac.coupon}")) { $coupon_code = FPRacCoupon::rac_create_coupon($order_object->billing_email, $each_cart->cart_abandon_time); $message = str_replace('{rac.coupon}', $coupon_code, $message); //replacing shortcode with coupon code } add_filter('woocommerce_email_footer_text', array('RecoverAbandonCart', 'rac_footer_email_customization')); $message = do_shortcode($message); //shortcode feature if (get_option('rac_email_use_temp_plain') != 'yes') { ob_start(); if (function_exists('wc_get_template')) { wc_get_template('emails/email-header.php', array('email_heading' => $subject)); echo $message; wc_get_template('emails/email-footer.php'); } else { woocommerce_get_template('emails/email-header.php', array('email_heading' => $subject)); echo $message; woocommerce_get_template('emails/email-footer.php'); } $woo_temp_msg = ob_get_clean(); } else { $woo_temp_msg = $message; } $headers = "MIME-Version: 1.0\r\n"; $headers .= "Content-Type: text/html; charset=UTF-8\r\n"; if ($emails->sender_opt == 'local') { $headers .= self::rac_formatted_from_address_local($emails->from_name, $emails->from_email); $headers .= "Reply-To: " . $emails->from_name . " <" . $emails->from_email . ">\r\n"; } else { $headers .= self::rac_formatted_from_address_woocommerce(); $headers .= "Reply-To: " . get_option('woocommerce_email_from_name') . "<" . get_option('woocommerce_email_from_address') . ">\r\n"; } if ($each_cart->sending_status == 'SEND') { //condition to check start/stop mail sending if ('wp_mail' == get_option('rac_trouble_mail')) { if (self::rac_send_wp_mail($to, $subject, $woo_temp_msg, $headers)) { // wp_mail($to, $subject, $message); $sent_mail_templates[] = $emails->id; $store_template_id = maybe_serialize($sent_mail_templates); $wpdb->update($abandancart_table_name, array('mail_template_id' => $store_template_id), array('id' => $each_cart->id)); //add to mail log $table_name_logs = $wpdb->prefix . 'rac_email_logs'; $wpdb->insert($table_name_logs, array("email_id" => $to, "date_time" => $current_time, "rac_cart_id" => $each_cart->id, "template_used" => $emails->id)); FPRacCounter::rac_do_mail_count(); } } else { if (self::rac_send_mail($to, $subject, $woo_temp_msg, $headers)) { // wp_mail($to, $subject, $message); $sent_mail_templates[] = $emails->id; $store_template_id = maybe_serialize($sent_mail_templates); $wpdb->update($abandancart_table_name, array('mail_template_id' => $store_template_id), array('id' => $each_cart->id)); //add to mail log $table_name_logs = $wpdb->prefix . 'rac_email_logs'; $wpdb->insert($table_name_logs, array("email_id" => $to, "date_time" => $current_time, "rac_cart_id" => $each_cart->id, "template_used" => $emails->id)); FPRacCounter::rac_do_mail_count(); } } } } } } } } } } } }