I need xstore hook for displaying ACF in archive pages

This topic has 10 replies, 3 voices, and was last updated 3 weeks, 3 days ago ago by Andrew Mitchell

  • Avatar: ziga32
    ziga32
    Participant
    January 15, 2025 at 15:11

    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( ‘

    [acf field="velikost_nosilnost"]

    ‘ );
    }

    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( ‘

    [acf field="velikost_nosilnost"]

    ‘ );
    }

    but only got this far 🙂
    https://share.cleanshot.com/85GDlYY3

    9 Answers
    Avatar: Jack Richardson
    Jack Richardson
    Support staff
    January 15, 2025 at 15:50

    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

    Avatar: ziga32
    ziga32
    Participant
    January 15, 2025 at 17:38

    Thank you very much.

    I added aan archive product module, added the code to funcitons.php, but acf field won’t show.

    https://share.cleanshot.com/cz8DwKKr

    Avatar: Jack Richardson
    Jack Richardson
    Support staff
    January 16, 2025 at 13:37

    Hello, @ziga32,

    We hope this message finds you well.

    Could you kindly confirm if you have enabled the Switcher for the specified option in your Archive Products widget? Additionally, we would appreciate it if you could provide us with the correct wp-admin access to your website so that we can review the configuration and assist you further.

    Thank you for your cooperation.

    Best regards,
    Jack Richardson
    The 8Theme Team

    Avatar: ziga32
    ziga32
    Participant
    January 16, 2025 at 14:05

    No I did not know I needed to, now it works, thank you.

    can it be moved to show under the title, not below the price, like in bottom row?
    https://share.cleanshot.com/t31KB8Hy

    Avatar: Jack Richardson
    Jack Richardson
    Support staff
    January 16, 2025 at 14:13

    Hello @ziga32
    Yes, please, try to change your next code ->

    add_filter('etheme_product_grid_list_product_elements', function($elements) {
    	$elements['velikost_nosilnost'] = esc_html__( 'ACF velikost nosilnost', 'xstore-child' );
    	return $elements;
    });

    with next one snippet ->

    add_filter('etheme_product_grid_list_product_elements', function($elements) {
    	$title_position = array_search('title', array_keys($elements));
    	if ( $title_position > 1 ) {
    		$elements = array_slice( $elements, 0, $title_position, true ) +
    		            array( 'velikost_nosilnost' => esc_html__( 'ACF velikost nosilnost', 'xstore-child' ) ) +
    		            array_slice( $elements, $title_position, count( $elements ) - $title_position, true );
    	}
    	else {
                   $elements['velikost_nosilnost'] = esc_html__( 'ACF velikost nosilnost', 'xstore-child');
    	}
    	return $elements;
    });

    Kind regards, Jack Richardson
    The 8theme’s team

    Avatar: ziga32
    ziga32
    Participant
    January 16, 2025 at 14:36

    thank you, but this now puts it above the title
    https://share.cleanshot.com/CLJFKr1L

    I updated the login pwd in case you need it

    Please contact administrator
    for this information.
    Avatar: Jack Richardson
    Jack Richardson
    Support staff
    January 16, 2025 at 15:39

    Hello @ziga32
    We have modified your code to output the custom element above the price -> https://prnt.sc/GAJGtD2utU4u. You can choose any of those keys from the list to sort and display your element in custom position with setting any value instead of the ‘price’ as it is set now.

    Elements list

    categories
    title
    rating
    price
    excerpt
    sku
    button

    Kind regards, Jack Richardson
    The 8theme’s team

    Avatar: ziga32
    ziga32
    Participant
    January 16, 2025 at 15:41

    very nice, as always, thank you!

    Avatar: Andrew Mitchell
    Andrew Mitchell
    Support staff
    January 16, 2025 at 15:41

    Dear ziga32,

    We trust our theme is enhancing your experience. Taking a brief moment to rate it with a glowing 5 stars on ThemeForest would be immensely appreciated. Your feedback holds significant value for us.

    Click here to rate now: https://themeforest.net/downloads

    Thank you sincerely for your ongoing support!

    Best Regards,
    The 8Theme Team

  • Viewing 10 results - 1 through 10 (of 10 total)

The issue related to '‘I need xstore hook for displaying ACF in archive pages’' has been successfully resolved, and the topic is now closed for further responses

We're using our own and third-party cookies to improve your experience and our website. Keep on browsing to accept our cookie policy.