예제 #1
0
    /** Author: ABU TAHER, Logic-coder IT
     * send_email_to_interest_confirmed
     * Param $email_data, $interest_confirmed_details
     * return Success/Failure Message
     */
    function send_email_to_interest_confirmed($email_data, $interest_confirmed_details, $deal_selection)
    {
        global $wpdb, $current_user;
        $bestbuy_bestsell_interest_list_object = new Bestbuybestsell_Interest();
        $current_user = wp_get_current_user();
        $dear_text = "";
        $interest_start_date = "";
        $interest_end_date = "";
        $group_price_list_text = "";
        $same_price_to_all = 0;
        $add_date = date("Y-m-d");
        $payment_email_sent = 0;
        $payment_confirmation_link_expire = "";
        $payment_confirmation_link_expire_text = "";
        $group_price_list_matched = "";
        $update_interest_data = "";
        $update_format_array = "";
        $update_case_data['no_of_sells'] = 0;
        $update_case_data['qty'] = 0;
        $update_case_data['unit_price'] = 0;
        $update_case_data['total_price'] = 0;
        $update_case_data['shipping_price'] = 0;
        $update_case_data['net_price'] = 0;
        //$time_now =
        if ($email_data['payment_within']) {
            $time_now = date("Y-m-d H:i");
            $payment_within = $email_data['payment_within'] / 24;
            $payment_confirmation_link_expire = date('Y-m-d H:i', strtotime($time_now . ' + ' . $payment_within . 'days'));
            $expire_date_time_separation = explode(" ", $payment_confirmation_link_expire);
            $expire_date = explode("-", $expire_date_time_separation[0]);
            $expire_time = explode(":", $expire_date_time_separation[1]);
            $payment_confirmation_link_expire_text = mktime($expire_time[0], $expire_time[1], 0, $expire_date[1], $expire_date[2], $expire_date[0]);
        }
        if ($interest_confirmed_details) {
            $count_interest_confirmed = $bestbuy_bestsell_interest_list_object->count_interest_confirmed($interest_confirmed_details[0]['product_id'], $interest_confirmed_details[0]['group_id']);
            //echo $count_interest_confirmed[0]->total_qty; exit;
            //////////////////////////////////////////////////////
            $product_meta_values = get_post_meta($interest_confirmed_details[0]['product_id'], '', '');
            $minimum_target_sells = $product_meta_values['minimum_target_sells'][0];
            $minimum_target_sells = 50;
            if ($count_interest_confirmed[0]['total_qty'] < $minimum_target_sells) {
                $group_price_list_matched = $bestbuy_bestsell_interest_list_object->get_minimum_price_list($interest_confirmed_details[0]['group_id']);
            } else {
                $group_price_list_matched = $bestbuy_bestsell_interest_list_object->get_group_price_list_matched($interest_confirmed_details[0]['group_id'], $count_interest_confirmed[0]['total_qty']);
            }
            //print_r( $group_price_list_matched ); exit;
            /////////////////////////////////////////////////////
            if ($group_price_list_matched) {
                foreach ($group_price_list_matched as $group_price_data) {
                    $update_case_data['no_of_sells'] = $group_price_data["no_of_sells"];
                    $update_case_data['unit_price'] = $group_price_data["bestbuy_bestsell_price"];
                    $update_case_data['shipping_price'] = $group_price_data["shipping_price"];
                    $group_price_list_text .= '<tr>
						<td><span>' . $group_price_data["no_of_sells"] . '</span></td>
						<td><span>' . $group_price_data["bestbuy_bestsell_price"] . '&nbsp;' . get_currency() . '</span></td>
						<td><span>' . $group_price_data["shipping_price"] . '&nbsp;' . get_currency() . '</span></td>
						</tr>' . "\n\n";
                }
            }
            foreach ($interest_confirmed_details as $individual_data) {
                /******************************************/
                $user_info = get_userdata($individual_data['user_id']);
                $user_meta_info = get_user_meta($individual_data['user_id'], '', '');
                //return (print_r( $user_meta_info )); exit;
                if ($user_meta_info['first_name'][0]) {
                    $dear_text = $user_meta_info['first_name'][0];
                } else {
                    $dear_text = $user_info->display_name;
                }
                if ($individual_data['interest_start_date']) {
                    $interest_start_date = date("Y-m-d", $individual_data['interest_start_date']);
                    $interest_end_date = date("Y-m-d", $individual_data['interest_end_date']);
                } else {
                    $interest_start_date = __("As soon as price is reasonable", TEXTDOMAIN);
                }
                /////////////////////// Start: Email Template ///////////////////////
                $subject = "Bestbuybestsell: " . $email_data["email_subject"] . " CaseNo(" . $interest_confirmed_details[0]['group_id'] . "_" . $individual_data['product_interest_id'] . ")\n\n";
                ob_start();
                include "email_header.php";
                ?>
                <p><?php 
                _e("Dear Customer", TEXTDOMAIN);
                ?>
 &nbsp;<?php 
                echo $dear_text;
                ?>
</p>
                <p><?php 
                echo $email_data["email_message_to_interest_grp"];
                ?>
 </p>
                <?php 
                //echo $deal_selection; exit;
                if ($deal_selection === 'want_to_deal') {
                    if ($individual_data['same_price_to_all'] || !intval($individual_data['interest_unit_price'])) {
                        //$same_price_to_all = 1;
                        ?>
                        <p><?php 
                        _e("A Price List is following for your interest", TEXTDOMAIN);
                        ?>
:</p>
                        <table cellpadding='5' cellspacing='2' bgcolor=#ffffff width='100%' style='margin:0 auto'>
                        <tr style='font-family: Verdana,Arial,Helvetica,sans-serif; font-size: 11px; color: 333333; line-height: 140%;'>
						<td><span style='font-weight:bold;'><?php 
                        _e("No Of Sells", TEXTDOMAIN);
                        ?>
</span></td>
						<td><span style='font-weight:bold;'><?php 
                        _e("Unit Price", TEXTDOMAIN);
                        ?>
</span></td>
						<td><span style='font-weight:bold;'><?php 
                        _e("Shipping Price", TEXTDOMAIN);
                        ?>
</span></td>
						</tr>
                        <?php 
                        echo $group_price_list_text;
                        ?>
</table>
                    <?php 
                    } else {
                        $update_case_data['no_of_sells'] = 0;
                        $update_case_data['unit_price'] = $individual_data['interest_unit_price'];
                        $update_case_data['shipping_price'] = $individual_data["interest_shipping_price"];
                        ?>
                        <p><?php 
                        _e("The Unit Price For Your Interest Is", TEXTDOMAIN);
                        ?>
:<?php 
                        echo get_currency() . " : " . $individual_data['interest_unit_price'];
                        ?>
</p>
                        <p><?php 
                        _e("Shipping Cost", TEXTDOMAIN);
                        ?>
:<?php 
                        echo get_currency() . " : " . $individual_data['interest_shipping_price'];
                        ?>
</p>
                <?php 
                    }
                }
                ?>
                <p><?php 
                _e("Your Interest Details", TEXTDOMAIN);
                ?>
:</p>
                <p><b><?php 
                _e("Product Name", TEXTDOMAIN);
                ?>
: </b>
                <a href="<?php 
                echo get_site_url();
                ?>
/index.php/my-interest-list/?action=edit&product_interest_id=<?php 
                echo $individual_data['product_interest_id'];
                ?>
&product_name=<?php 
                echo $individual_data['post_name'];
                ?>
" ><?php 
                echo $individual_data['product_name'];
                ?>
 </a></p>
                <p><b><?php 
                _e("Qty", TEXTDOMAIN);
                ?>
: </b><?php 
                echo $individual_data['interest_qty'];
                ?>
 </p>
                <p><b><?php 
                _e("Interest Start Date", TEXTDOMAIN);
                ?>
: </b><?php 
                echo $interest_start_date;
                ?>
</p>
                <p><b><?php 
                _e("Interest End Date", TEXTDOMAIN);
                ?>
: </b><?php 
                echo $interest_end_date;
                ?>
</p>
                <?php 
                if ($deal_selection == "want_to_deal") {
                    if ($email_data['payment_within']) {
                        ?>
                        <p><?php 
                        _e("You Have", TEXTDOMAIN);
                        ?>
&nbsp;<?php 
                        echo $email_data['payment_within'];
                        ?>
                            <?php 
                        _e("Hours For Payment to confirm that you are still want to purchase this product for the above Details", TEXTDOMAIN);
                        ?>
                        </p>
                   <?php 
                    }
                    ?>
                    <p><?php 
                    _e("For Payment Please click on This Link", TEXTDOMAIN);
                    ?>
:
                        <a href="<?php 
                    echo get_site_url();
                    ?>
/index.php/my-interest-summary/?product_interest_id=<?php 
                    echo $individual_data['product_interest_id'];
                    ?>
" ><?php 
                    _e("Yes", TEXTDOMAIN);
                    ?>
</a>
					</p>
                <?php 
                }
                include "email_footer.php";
                $message = ob_get_contents();
                ob_end_clean();
                $email_to = $user_info->user_email;
                $update_format_array = array('%s', "%s", "%s");
                //if( mail( $email_to , $subject,"",$header) )	{
                if (wp_mail($email_to, $subject, $message)) {
                    //$case_data['product_interest_id'] = $individual_data->product_interest_id;
                    $update_case_data['qty'] = $individual_data['interest_qty'];
                    $update_case_data['total_price'] = calculate_total_price($update_case_data['qty'], $update_case_data['unit_price']);
                    $update_case_data['net_price'] = calculate_net_price($update_case_data['total_price'], $update_case_data['shipping_price']);
                    $update_case_data['payment_subject'] = $subject;
                    $update_case_data['payment_message'] = $message;
                    $update_case_data['payment_within'] = $email_data['payment_within'];
                    $where = array("product_interest_id" => $individual_data['product_interest_id']);
                    $where_format = array();
                    //print_r( $update_case_data ); exit;
                    $wpdb->update("{$wpdb->prefix}interest_group_case", $update_case_data, $where, $update_format_array = null, $where_format = null);
                    if (!$email_sent) {
                        $update_group_data = array("payment_email_sent" => 1);
                        $where = array("group_id" => $interest_confirmed_details[0]['group_id']);
                        $update_format_array = array('%d');
                        $where_format = array();
                        $wpdb->update("{$wpdb->prefix}interest_group", $update_group_data, $where, $update_format_array = null, $where_format = null);
                        $email_sent = 1;
                    }
                    if ($deal_selection == "want_to_deal") {
                        $update_interest_data = array("interest_campaign_closed" => 0, "payment_confirmation_link_expire" => $payment_confirmation_link_expire_text);
                        $update_format_array = array('%d', '%s');
                    } elseif ($deal_selection == "deal_closed_successfully") {
                        $update_interest_data = array("interest_campaign_closed" => 1);
                        $update_format_array = array('%d');
                    } elseif ($deal_selection == "dealings_fail") {
                        $update_interest_data = array("interest_confirmed" => 0, "interest_campaign_closed" => 2, "interest_confirmation_link_expire" => 0);
                        $update_format_array = array('%d', '%d', '%s');
                    }
                    $where = array("product_interest_id" => $individual_data['product_interest_id']);
                    $where_format = array();
                    $wpdb->update("{$wpdb->prefix}product_interest", $update_interest_data, $where, $update_format_array = null, $where_format = null);
                }
                /******************************************/
            }
        }
        if ($email_sent) {
            return True;
        }
    }
예제 #2
0
    ?>
 />

				<form action="cart.php" method="POST">
					<input type="hidden" name="id" value="<?php 
    echo $cart_item[0];
    ?>
" />
					<br><input name="remove" type="submit" value="Remove" class="login-button" style="width: 20%"/><hr style="margin-top: 0.5em">
				</form>
				<br/>
			<?php 
}
?>
			<?php 
$total = calculate_total_price($cart_id);
// total price
if ($total > 0) {
    echo "<p id=\"login-p\" style=\"font-weight: bold\">Total: \$" . $total . "</p>";
    ?>
			<br>
			<input form="update" type="submit" name="update" value="Update Shopping Cart" class="login-button"/>
			<form action="cart.php" method="POST">
				<br><input type="submit" name="checkout" value="Checkout" class="login-button"><br>
			</form>
			<form action="cart.php" method="POST">
				<br><input type="submit" name="clear" value="Clear Shopping Cart" class="login-button"/>
			</form>
			<?php 
} else {
    echo "<p id=\"cart-h1\">Shopping Cart is Empty</p>";
예제 #3
0
                $addonKey = $addon;
                $addonValue = 'selected';
            } else {
                // A valid selection!
                $addonValue = $addonValues[$addon];
                if (in_array($addonValue, $optionsDb->{$addonKey}->choices) == FALSE) {
                    die('Invalid Addon choice, ' . $addon . 'cannot be $value for ' . $product_id . ' product');
                }
            }
            array_push($addonSelections, array($addon, $addonValue, $addonTitle));
        } else {
            die('Invalid addon ' . $addon . ' is not valid for ' . $product_id . ' product');
        }
    }
}
// Validate Options and Addons which don't affect the price
// All options must be valid for this product
foreach ($options as $option => $value) {
    // Is this product allowed to have this option?
    if (in_array($option, array_keys(get_object_vars($productDb->options)))) {
        // Is the value of this option a legal value?
        $optionKey = $productDb->options->{$option}->options;
        if (in_array($value, $optionsDb->{$optionKey}->choices) == FALSE) {
            die("{$option} cannot be set to {$value} for the {$product_id} product");
        }
    } else {
        die("{$option} option isn't valid for the {$product_id} product");
    }
}
$total_price = calculate_total_price($product_id, $productDb, $optionsDb, $addonsSelected, $feederSize);
$stripe_description = $productDb->name . ' ' . $productDb->subtitle . ' total: $' . $total_price;