• Resolved rayblackwell

    (@rayblackwell)


    Good afternoon from Spain!

    I hope you could help me with this issue in my single product page.

    https://www.emblemarket.com/producto/medalla-pequena-oro-centro-25/

    Once you have chosen a variation and click on «personalizar mi medalla» button, a Fancy Product Designer editor is shown. I placed it the with a custom hook inserted in content-single-product of woocommerce:

    /**
    * Hook: woocommerce_before_single_product.
    *
    * @hooked wc_print_notices – 10
    */
    do_action( ‘woocommerce_before_single_product’ );
    if ( post_password_required() ) {
    echo get_the_password_form(); // WPCS: XSS ok.
    return;
    }
    ?>
    <?php
    /**
    *PosicionFPD
    */
    do_action( ‘fpd_product_designer’ );
    ?>

    and my questions are:

    1) There is no space between the product editor and product summary. In fact, the editor shadow is cut. ¿How can I introduce an space here?

    2) ¿Can I insert the custom hook in the snippets editor? I don`t like to modify the woocommerce template.

    Thank you very much!
    Sorry for my english…
    Gracias!

    Kind regards.

    Ricardo.

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hello! @rayblackwell

    If you have a child theme for your theme (which I strongly recommend since you’re doing custom work) you can copy the content-single-product.php WooCommerce template to your child theme /woocommerce/single-product/ folder (make the folder if it doesn’t exist).

    Then you can make edits to your child-theme/woocommerce/single-product/content-single-product.php file that will never get over-written with updates. These changes will show on the front end because Woo has a templating system.

    Doing something like:

    /**
    * Hook: woocommerce_before_single_product.
    *
    * @hooked wc_print_notices – 10
    */
    do_action( ‘woocommerce_before_single_product’ );
    if ( post_password_required() ) {
    echo get_the_password_form(); // WPCS: XSS ok.
    return;
    }
    // insert a <br> or some other HTML to format a space below here: ?>
    <br />
    <?php
    /**
    *PosicionFPD
    */
    do_action( ‘fpd_product_designer’ );
    ?>

    Would probably help, but you could use other HTML tags with CSS to achieve your intended result, maybe just wrap the fpd_product_designer in a <div>.

    Hopefully you understand and this helps you. 🙂

    Thread Starter rayblackwell

    (@rayblackwell)

    Thank you very much!

    Finally I did this:

    <div id="fancyportacentros">
    <?php
    /**
    *PosicionFPD
    */
    do_action( 'fpd_product_designer' ); 
    ?>
    &nbsp;
    </div>

    It was that simple! 🙂

    I asume reading your answer that is not possible to set up this hook with the snippets plugin. Am I right?

    • This reply was modified 6 years, 3 months ago by rayblackwell.
    • This reply was modified 6 years, 3 months ago by rayblackwell.

    @rayblackwell

    Are you saying you’d like to later on do something like:

    add_action( 'fpd_product_designer', 'fpd_product_designer_fx' )
    function fpd_product_designer_fx() {
        // output etc. etc. etc.
    }

    and need a place to insert that script on your site? Personally I’d do it in a child theme functions.php file… but maybe you can do it as a snippet. You can try!

    Thread Starter rayblackwell

    (@rayblackwell)

    Yes!

    I’ll try to do it as a snippet, but I already have lots of work to do and no time! :S For now, it’s working, so I’ll copy the content-single-product to my theme to avoid problems with updates..

    Thank you again for your help.

    Have a great day!

    Ricardo.

    @rayblackwell Hopefully you meant “child theme” when you said “copy the content-single-product to my theme to avoid problems with updates,” because if you just copy it to your parent theme, and update that, it will be over-written. Sorry if this is too obvious. Good luck!

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Custom Hook placement.’ is closed to new replies.