Your basket is currently empty!
$product_title,
‘content’ => $product_description,
‘status’ => ‘publish’,
‘price’ => $product_price,
‘sku’ => ‘custom_sku’, // Replace with your desired SKU
// Add any other product fields as needed
);
$headers = array(
‘Authorization’ => ‘Basic ‘ . base64_encode($api_username . ‘:’ . $api_password),
‘Content-Type’ => ‘application/json’,
);
$response = wp_remote_post($api_endpoint, array(
‘headers’ => $headers,
‘body’ => json_encode($product_data),
));
if (is_wp_error($response)) {
// Handle error response
$error_message = $response->get_error_message();
echo “Error: ” . $error_message;
} else {
// Retrieve the product URL from the response
$product_url = json_decode(wp_remote_retrieve_body($response), true)[‘link’];
?>
↑