Skip to content

Instantly share code, notes, and snippets.

@webtoffee-git
Created November 11, 2024 06:15
Show Gist options
  • Save webtoffee-git/a828aef70abcbee5fc7211b1394fe73e to your computer and use it in GitHub Desktop.
Save webtoffee-git/a828aef70abcbee5fc7211b1394fe73e to your computer and use it in GitHub Desktop.
Code snippet to alter product image URL in documents - by WebToffee ( WooCommerce PDF Invoice, Packing Slips, Delivery Notes and Shipping labels (free)
<?php //Do not copy this line of code
add_filter('wt_pklist_alter_product_image_url', 'wt_pklist_alter_product_image_url_fn', 10, 4);
/**
* Filter to customize the product image URL in packing lists.
*
* This function allows you to set a custom image URL for a product.
* If a custom image URL is available, update the `$img_url` variable to use that URL.
* @return string The updated image URL to be used in the packing list.
*/
function wt_pklist_alter_product_image_url_fn($img_url, $product_id, $variation_id, $parent_id) {
// Retrieve your custom image URL here (if needed)
$img_url = 'http://backend-test.local/wp-content/uploads/2024/08/images-1.jpeg';
return $img_url;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment