Created
December 7, 2024 09:36
-
-
Save emre-edu-tech/0ee181d7a8c1ba48c357c1178dfd1f02 to your computer and use it in GitHub Desktop.
Add an ACF field after shop item title on Shop or Product Category page template
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action('woocommerce_after_shop_loop_item_title', 'add_custom_product_info', 18); | |
function add_custom_product_info() { | |
global $product; | |
$product_unit_price = get_field('unit_price', $product->id); | |
// Displaying the custom field only when is set with a value | |
if(!empty($product_unit_price )) { | |
// Change text-domain with your own. | |
echo '<p style="color: red; font-weight: 600; font-size: 1.2rem">' . __('Ab ', 'text-domain') . $product_unit_price . '€ / Stück</p>'; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment