This topic has 3 replies, 2 voices, and was last updated 6 minutes ago ago by ziga32
I’m using PRODUCTS widget/module in elementor theme builder to build an archive layout.
I’m also using a ACF custom field “velikost_nosilnost” which is shown after product title here
https://ergovision.si/gaming-stoli/
https://share.cleanshot.com/tQ81kJXM
This is the code I’m using.
add_action( ‘woocommerce_after_shop_loop_item_title’, ‘bbloomer_show_free_shipping_loop’, 5 );
function bbloomer_show_free_shipping_loop() {
echo do_shortcode( ‘
‘ );
}
Works fine, but PRODUCTS widget is now deprecated and I need to switch to xstore’s ARCHIVE PRODUCTS widget.
I made it so it looks exactly the same, but now ACF field is not showing cause xstore uses different hooks I guess.
I tried this hook
add_action( ‘etheme_product_grid_list_product_elements’, ‘bbloomer_show_free_shipping_loop’, 5 );
function bbloomer_show_free_shipping_loop() {
echo do_shortcode( ‘
‘ );
}
but only got this far 🙂
https://share.cleanshot.com/85GDlYY3
Hello @ziga32
It looks like you checked the topic we suggested to you (https://www.8theme.com/topic/put-a-custom-button-in-product-grid-below-add-to-cart/#post-348635) but made the code snippet in your custom way without following the requirement steps and using the incorrect hooks.
Please, try instead of your one the next one to be added in your child-theme/functions.php
add_filter('etheme_product_grid_list_product_elements', function($elements) {
$elements['velikost_nosilnost'] = esc_html__( 'ACF velikost nosilnost', 'xstore-child' );
return $elements;
});
add_action( 'etheme_product_grid_list_product_element_render', function($key, $product, $edit_mode, $main_class) {
if ( $key == 'velikost_nosilnost' ) {
echo do_shortcode( '[acf field="velikost_nosilnost"]' );
}
}, 10, 4 );
Also, once you add such snippet you should see the new switcher in the Product Archive element that should be enabled and then you will see the custom field output on your products.
Kind regards, Jack Richardson
The 8theme’s team
Thank you very much.
I added aan archive product module, added the code to funcitons.php, but acf field won’t show.
You must be logged in to reply to this topic.Log in/Sign up