SHARE
TWEET

WP cart form. send product cookie

npofopr Dec 3rd, 2019 115 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function cart_form(){
  2.   $multiple_recipients = array(
  3.     get_option('admin_email')
  4.   );
  5.   $message = '';
  6.   $message .= "Имя: ".$_POST['u-name']."\n\r";
  7.   $message .= 'Телефон: '.$_POST['u-telephone']."\n\r";
  8.   $message .= "Удобное время: ".$_POST['u-time']."\n\r";
  9.   $message .= "Город: ".$_POST['u-city']."\n\r";
  10.   $message .= "Email: ".$_POST['u-mail']."\n\r";
  11.   $cartProducts = json_decode(str_replace("\\", "", $_COOKIE['cart_products']));
  12.   if($cartProducts) {
  13.     $sum = 0;
  14.     foreach ($cartProducts as $product) {
  15.       $price = get_post_meta($product->id, 'price', true);
  16.       $sum += $price*$product->numb;
  17.       $message .= "\n\r";
  18.       $message .= "\nНаименование товара: ".get_the_title($product->id);
  19.       $message .= "\nID товара: ".$product->id;
  20.       $message .= "\nКоличество товара: ".$product->numb;
  21.     }
  22.   }
  23.  
  24.   // if(wp_mail( get_option('admin_email'), $_POST['u-theme'], $message)){
  25.   if(wp_mail( $multiple_recipients, $_POST['u-theme'], $message)){
  26.       die('true');
  27.     }
  28.   exit();
  29. }
  30.  
  31. // Содержимое куки:
  32. // Name cart_products
  33. // Value    {"2140":{"id":2140,"numb":1}}
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top