[Resolved] Gutenenberg Pages Woocomerce Block Hook

Home Forums Support Gutenenberg Pages Woocomerce Block Hook

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #1108575
    FunkyCss

    Hi , Can we use a hook or filter on simple pages to show ACF .

    So i have created for each woocomerce product a custom field that is a subtitle . and i can show them on woo pages with a simple hook .

    But is this possible or any hook available for not woocomerce pages and simple pages . i have to notice that pages are created with woocomerce short code inside gutenberg editor .

    #1109014
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    I’m not too sure what you mean – you should be able to hook anything into your site, regardless of the page.

    Have you checked out the Hook Element?: https://docs.generatepress.com/article/hooks-element-overview/

    In the Display Rules you can include/exclude pages, products etc..

    Let me know 🙂

    #1109459
    FunkyCss

    Tom thank you for your reply ! I have tried Hook Elements and its one of the greatest things i have ever used! has helped me a million of times on my projects and clients like it !

    What i say is , i have created a field with ACF on Woocomerce products , its a like a subtitle .

    With this php code

    add_action( 'woocommerce_single_product_summary', 'display_acf_field_under_title', 6 );
    function display_acf_field_under_title() {
    echo '<span class="woo-subtitle">' . get_field('subtitle_'). '</span>';
    }

    I can show them on woo pages .

    And with this one

    remove_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_template_loop_product_thumbnail', 10 );
    add_action( 'woocommerce_shop_loop_item_title', 'woocommerce_template_loop_product_thumbnail', 11 );
    

    I transfer Product name above Image . THis is easy .

    But i have a page created with Gutenberg and i dont know how to access and make this changes there .

    I mean i use Woocomerce Gutenberg blocks to show my categories in the page , but i cant show the ACF fields !

    #1109537
    FunkyCss

    I would apreciate if there is any tip on how to do this one

    #1109638
    David
    Staff
    Customer Support

    Hi there,

    unfortunately the Woo Guteneberg Blocks don’t use the core woo templates so don’t contain any hooks.

    Have you tried using the Woo Shortcodes instead?

    #1109655
    FunkyCss

    Hi David once again ! I did not think about shortcodes actually ! How is possible to call custom fields with short codes ?

    #1109691
    David
    Staff
    Customer Support

    Sorry I thought you were Hooking ACF fields to be displayed in the Woo templates.

    ACF has its own shortcakes:

    https://www.advancedcustomfields.com/resources/shortcode/

    #1109830
    FunkyCss

    Yeah maybe this is the only solution , a combo of this – > https://stackoverflow.com/questions/50672469/add-a-custom-field-variable-acf-to-a-custom-woocommerce-shortcode

    and the acf shortcodes maybe , i will give it a try

    #1109832
    FunkyCss

    Actually the best practice for someone is to create a custom woo archive template where you can easily work on it , but now is been maded with gutenberg so i have to try it with what i have , but my advice for someone that has the same is go with custom php template .

    #1109849
    David
    Staff
    Customer Support

    Yeah Gutenberg does ‘mix’ things up a bit. You may want to look into ACF Blocks as well:

    https://www.advancedcustomfields.com/resources/blocks/

Viewing 10 posts - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.