Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function send_order_now(){
- $name = $_POST['name'];
- $email = $_POST['email'];
- $tel = $_POST['tel'];
- $address = $_POST['address'];
- $city = $_POST['city'];
- $postal = $_POST['postal'];
- $country = $_POST['country'];
- add_filter( 'wp_mail_content_type','mail_set_content_type' );
- $client_info = "<h3>Podaci poručioca</h3><br><strong>Ime i prezime</strong>: ".$name."</br><strong>Email adresa</strong>: ".$email."<br><strong>Telefon</strong>: ".$tel."<br><strong>Adresa</strong>:".$address." ".$postal." ".$city.", ".$country."<br><br><h3>Narudžba:</h3>";
- $product_table = $product_tabel.'<table border="1" style="background-color:#ffffff;border-collapse:collapse;border:1px solid #CBCBCB;color:#000000;width:100%" cellpadding="5" cellspacing=""><tr><td>Naziv proizvoda</td><td>Količina</td><td>Cijena po kom</td><td>Ukupna cijena</td></tr>';
- $servername = "localhost";
- $username = "cubegame_imarket";
- $password = "IslamMarket20!5";
- $conn = new mysqli($servername, $username, $password);
- $conn->select_db("cubegame_islammarket");
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- $key = $_COOKIE['imbshop_cart'];
- $cart_db = $conn->query("SELECT * FROM wp_islammarket_cart WHERE user_key = '$key'");
- $total_price_all = 0;
- while ($row = $cart_db->fetch_assoc()) {
- $id = $row['product_id'];
- $counter = $row['counter'];
- $title = get_the_title($id);
- $action_article = get_post_meta($id, 'imb_artikl_akcija', true);
- $price = get_post_meta($id, 'imb_artikl_cijena', true);
- $action_price = get_post_meta($id, 'imb_artikl_cijena_akcija', true);
- $url = get_permalink($id);
- $attrs = get_post_meta($id, 'imb_atribut', true);
- $total_price = 0;
- $product_table = $product_tabel."<tr><td>".$title."<br>";
- foreach($attrs as $attr){
- $product_table= $product_table."<strong>".$attr['_naziv']."</strong>: ".$attr['_vrijednost']." ";
- }
- $product_table= $product_table."</td><td>".$counter."</td><td>";
- if($action_article=="on"){
- $product_table= $product_table." ".number_format((float)$action_price, 2, '.', '')."KM";
- $total_price = $counter*$action_price;
- } else {
- $product_table = $product_table." "number_format((float)$price, 2, '.', '')."KM";
- $total_price = $counter*$price;
- }
- $product_table= $product_table."</td><td>".number_format((float)$total_price, 2, '.', '')."KM</td></tr>";
- $total_price_all = $total_price_all + $total_price;
- $total_price = 0;
- }
- mysqli_close($conn);
- $product_table= $product_table."<tr><td colspan='4' style='text-align:right;'>Ukupno za platit</td><td>".number_format((float)$total_price_all, 2, '.', '')."KM</td>";
- $product_table = $product_table.'</table>';
- $to = "emir.memisevic.ets@gmail.com";
- $subject = "Narudžba ".substr(md5(time()),0,5);
- $content = $client_info. " ".$product_table;
- $headers = 'From: Islam Market Bosna <no-reply@imbeshop.com>' . "\r\n";
- $status = wp_mail($to, $subject, $content, $headers, false);
- remove_filter( 'wp_mail_content_type','mail_set_content_type' );
- return $status;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement