[Support request] How to edit a woocommerce product page (to add custom fields)

Home Forums Support [Support request] How to edit a woocommerce product page (to add custom fields)

Home Forums Support How to edit a woocommerce product page (to add custom fields)

  • This topic has 3 replies, 2 voices, and was last updated 2 months ago by David.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #2021010
    Patrick

    Hello, I’m migrating my comic book store site to GP, everything went remarkably well, except that my custom fields “Author’s name” and “Publication date” are not visible on the product page.
    It may be right in front of my nose, but I’ve been stalling for a few hours…
    Sincerely

    #2021188
    David
    Staff
    Customer Support

    Hi there,

    you will need to ‘hook’ in the custom fields.
    Can you share link to your product page so i can see the layout, and let me know where those custom fields should be displayed?

    #2021284
    Patrick

    Many thanks for the answer.
    The link: https://ndf2.cw56.net/produit/amulet-t3-les-chercheurs-de-nuages/

    After my request for help, I installed ACF and I managed to insert text by modifying /domain/wp-content/themes/generatepress_child/woocommerce/content-single-product.php
    I was able to add “Parution : 10/11/2021” and “Auteur: yerbouti” below the “Add to cart” button
    As it is, there is only one more CSS adjustment to do (I know how to do).
    I would have liked to be able to modify the product page directly from the administration interface, but it may be impossible.

    How to change the presentation of the elements provided by “do_action( ‘woocommerce_single_product_summary’ );” but I do not know how to do. I would like for example to put the author just below the title.

    #2021308
    David
    Staff
    Customer Support

    Ok – so first off this is a really handy guide for all the Hooks on the single product page:

    https://www.businessbloomer.com/woocommerce-visual-hook-guide-single-product-page/

    So below the visual guide you can see the default actions. In particular you can see the Title is hooked in like so:

    add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_title', 5 );

    So you can hook in below that using the same Hook and higher priority eg. 7:

    add_action( 'woocommerce_single_product_summary', 'function_callback_below_the_single_title', 7 );

    And in GP you can ‘hook’ into the templates using the Hook Element:

    https://docs.generatepress.com/article/hooks-element-overview/

    Which you can add your PHP snippet to get the Custom Field.

    Or the Block Element:

    https://docs.generatepress.com/article/block-element-overview/

    Where you can use the GenerateBlocks plugin to get dynamic data for that Post Meta.
    You can see it being used in various ways here:

    https://docs.generatepress.com/?s=block+element+-

    Both Elements will display the various Woocommerce Hooks in their list and you have a Priority field as well.

    Using any of these Hook methods – then you don’t need the child theme templates 🙂

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