/*
$id_producto=$_POST['id_producto'];
$precio=$_POST['precio'];
$descripcion=$_POST['descripcion'];
$titulo=$_POST['titulo'];
$img=$_FILES['file']['name']'.' . pathinfo($_FILES['file']['name'], PATHINFO_EXTENSION);;
Supongamos que en el codigo de arriba ya subiste la
- imagen del producto
- la descripcion
- el titulo
- el precio y
- el id del producto
=> Vamos a crear un archivo dinamico que contenga las meta que requiere WhatsApp
*/
$ruta_php = $_SERVER['DOCUMENT_ROOT'] . '/carpetaX/' . $id_producto . ' .php';
$ruta_img = $_SERVER['DOCUMENT_ROOT'] . '/carpetaX/' . $img;
/* creamos el texto del WhatsAapp */
$text = "https://api.whatsapp.com/send?";
$text .= "phone=+585555555&text=Hola,%20EmpresaX%20quiero%20pedir%20informacion%20de%20este%20producto%0A%0A";
$text .= "" . $titulo . "%0A";
$text .= "Precio%20:%20" . $precio . "%0A%0A";
$text .= "Publicado%20por%20ustedes%0A%0A" . $ruta_php . "%0A";
/* creamos el php dinamico */
if (file_exists($ruta_php)) unlink($ruta_php);
$fh = fopen($ruta_php, 'w');
$puts = '<!DOCTYPE HTML>';
$puts .= "\n";
$puts .= '<html lang="es">';
$puts .= "\n";
$puts .= '<head>';
$puts .= "\n";
$puts .= '<meta name="description" content="' . $descripcion . '" />';
$puts .= "\n";
$puts .= '<meta property="og:title" content="' . $titulo . '" />';
$puts .= "\n";
$puts .= '<meta property="og:type" content="article" />';
$puts .= "\n";
$puts .= '<meta property="og:description" content="' . $descripcion . '" />';
$puts .= "\n";
$puts .= '<meta property="og:locale" content="es_LA" />';
$puts .= "\n";
$puts .= '<meta property="og:site_name" content="merca.red" />';
$puts .= "\n";
$puts .= '<meta property="og:image" content="' . $ruta_img . '" />';
$puts .= "\n";
$puts .= '<meta property="og:image:width" content="1200" />';
$puts .= "\n";
$puts .= '<meta property="og:image:height" content="630" />';
$puts .= "\n";
$puts .= '<title>' . $titulo . '</title>';
$puts .= "\n";
$puts .= '<link rel=icon href="' . $ruta_img . '" sizes="300x300" type="image/jpg" />';
$puts .= "\n";
$puts .= '</head>';
$puts .= "\n";
$puts .= '<body>';
$puts .= "\n";
$puts .= '<script>';
$puts .= "\n";
$puts .= 'location.href="' . $text . '";';
$puts .= "\n";
$puts .= '</script>';
$puts .= "\n";
$puts .= '</body>';
$puts .= "\n";
$puts .= '</html>';
fputs($fh, $puts);
fclose($fh);
/*
Listo!
Ahora del lado del cliente cuando pulsen el boton de
OrderWhatsApp apunta el href a la direccion $ruta_php
*/