Since I’ve setup this plugin, I have weird bugs happening when it comes to setting order meta data and then reading them a few milliseconds later in another function/method. Function A creates an order and sets some meta data, then executes function B. Function B have null value while using get_post_meta() even though database stored the meta values.
So I think it’s safe to say that there is an issue involving caching here.
I’d like to know if there is a way to avoid any caching related to woocommerce orders and their metas. I’m only using DB and object cache through Redis.
Best regards,
]]>is there a way to import all the meta data (title, description) from another SEO plugin (Slim Seo), instead of having to re-write it all on all the pages-posts of my site? If so, how can I do to import them?
Thank you in advance
How to remove it?
]]>_regular_price and _thumbnail_id being column headings, and “125” and “3416” being the corresponding data for a particular product.
However, I have meta data headings that show like this:
_upsell_ids being the column head with “? 0” being the first upsell product with ID “3816” and “? 1” being the second upsell product with ID “3810”.
Exporting to CSV only gives me the main heading of _upsell_id, but i can’t figure out how to structure the CSV to upload the ? 0 and ? 1 fields.
Anyone know how to do this, or if it’s possible?
Thanks!
]]>The select field has two columns:
I can easily export the first column field using “office” as the metadata. However, I can’t figure out how to export the second column (the actual address)… I’ve used every variation of “select2” that I can see!
FYI, the link takes you to a product to add to cart and checkout where you will see the dropdown. Please don’t complete an order.
Any help or guidance would be greatly appreciated.
Thank you!
]]>Thank you!
]]>I am using the following codes to add an image to the media library:
function add_new_image_to_post(string $image_filename, int $parent_post_id)
{
// Create the new attachment post for the image
// Check the type of file. We'll use this as the 'post_mime_type'.
$filetype = wp_check_filetype(basename($image_filename), null);
output_debug_text(sprintf('File type of the image: %s.', $filetype['type']));
// Get the path to the upload directory.
$wp_upload_dir = wp_upload_dir();
output_debug_text(sprintf('Upload dir: %s.' . PHP_EOL, $wp_upload_dir['url']));
// Prepare an array of post data for the attachment.
$attachment = array(
'guid' => $wp_upload_dir['url'] . '/' . basename( $image_filename ),
'post_mime_type' => $filetype['type'],
'post_title' => '',
'post_content' => '',
'post_status' => 'inherit'
);
// Insert the attachment.
$attach_id = wp_insert_attachment( $attachment, $image_filename, $parent_post_id );
if ($attach_id)
{
output_debug_text(sprintf('Insert attachment successfully. Image file: %s. Parent post ID: %s. Attach ID: %s.' . PHP_EOL, $image_filename, $parent_post_id, $attach_id));
// Make sure that this file is included, as wp_generate_attachment_metadata() depends on it.
require_once( ABSPATH . 'wp-admin/includes/image.php' );
// Generate the metadata for the attachment, and update the database record.
$attach_data = wp_generate_attachment_metadata( $attach_id, $image_filename );
if ($attach_data)
{
output_debug_text('Generate attachment meta data successfully: ' . print_r($attach_data, true) . PHP_EOL);
$result = wp_update_attachment_metadata( $attach_id, $attach_data );
// $result will be false, but the attachemnt is added successfully and all subimages are created
// so we will ignore the case and always return $attach_id
// Ref: https://www.ads-software.com/support/topic/wp_update_attachment_metadata-always-return-false/#post-17486245
$result = true;
if ($result)
{
output_debug_text(sprintf('Set attachment metadata successfully.' . PHP_EOL));
return $attach_id;
}
else
output_debug_text(sprintf('Fail to set attachment metadata.\n'));
}
else
output_debug_text(sprintf('Fail to generate attachment metdata.\n'));
}
else
output_debug_text(sprintf('Fail to insert image attachment.\n'));
return 0;
}
I dump the $attach_data. Then under a Windows 10 + Wampserver64, wp_generate_attachment_metadata will generate images with different sizes, as below:
Array
(
[width] => 1190
[height] => 680
[file] => C:/wamp64/www/blogs/wp-content/uploads/2024/03/test11.jpg
[filesize] => 122205
[sizes] => Array
(
[medium] => Array
(
[file] => test11-300x171.jpg
[width] => 300
[height] => 171
[mime-type] => image/jpeg
[filesize] => 14252
)
[large] => Array
(
[file] => test11-1024x585.jpg
[width] => 1024
[height] => 585
[mime-type] => image/jpeg
[filesize] => 94116
)
[thumbnail] => Array
(
[file] => test11-150x150.jpg
[width] => 150
[height] => 150
[mime-type] => image/jpeg
[filesize] => 7239
)
[medium_large] => Array
(
[file] => test11-768x439.jpg
[width] => 768
[height] => 439
[mime-type] => image/jpeg
[filesize] => 59274
)
)
[image_meta] => Array
(
[aperture] => 0
[credit] =>
[camera] =>
[caption] =>
[created_timestamp] => 0
[copyright] =>
[focal_length] => 0
[iso] => 0
[shutter_speed] => 0
[title] =>
[orientation] => 0
[keywords] => Array
(
)
)
)
But in a CentOS 7 server(Linux), [filesize] is zero, and no sizes are generated:
Array
(
[width] => 1190
[height] => 680
[file] => https://www.sample.com/blogs/wp-content/uploads/2024/03/outlook-pst-repair-2.jpg
[filesize] => 0
[sizes] => Array
(
)
)
I check the post for the image, it looks like this:
https://pasteboard.co/FgoTtHcaWH3W.png
It seems the meta data for the attachment is not generated successfully. But there is still an array returned. Why? How to diagnose the issue? I check https://developer.www.ads-software.com/reference/functions/wp_generate_attachment_metadata/ but cannot find how to obtain an error code if the function fails.
]]>