• Resolved designerken

    (@kcharity)


    I am trying to override the template file.

    In my child-theme I created the folder structure:
    woocommerce/global/quantity-input.php

    I changed the template but I do not see anything on the front end.

    Basically I am trying to change the <input type="button"> to the newer <button> element.

    Any ideas as to why the override would not be read, there is no cache on the site and if I manually change the plug-in code it changes on the front end.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Niels Lange

    (@nielslange)

    Hello @kcharity ?? Thanks for reaching out!

    I changed the template but I do not see anything on the front end.

    Basically I am trying to change the <input type="button"> to the newer <button> element.

    Any ideas as to why the override would not be read, there is no cache on the site and if I manually change the plug-in code it changes on the front end.

    The SMNTCS Quantity Increment Buttons for WooCommerce plugin expects the input buttons to look like this:

    <input class="plus" type="button" value="+">
    <input class="minus" type="button" value="-">

    Changing the input buttons, will lead to the fact that the buttons can no longer be detected by the plugin. The logic to detect the corresponding buttons takes place in https://github.com/nielslange/smntcs-quantity-buttons-for-woocommerce/blob/trunk/template/global/quantity-input.php.

    May I ask why you want to change <input type="button"> to <button>?

    Thread Starter designerken

    (@kcharity)

    I did notice the functionality was lost when changing the plug-in directly, so I would need to figure that out eventually.

    My main concern is that creating the template file had no effect on the front end, the code remained the same, there was no override.

    The reason I would like to change it is for better control of the element and being able to style it better, and possibility of using SVG icons instead of text.

    I was simply trying to acheve something like this:
    <button class="minus">-</button>

    While?<input>?elements of type?button?are still perfectly valid HTML, the newer?<button>?element is now the favored way to create buttons. Given that a?<button>‘s label text is inserted between the opening and closing tags, you can include HTML in the label, even images.

    So to my first point, what should I look for with the template not being overridden? And secondly, do you plan on ever moving over to a button vs. input?

    Plugin Author Niels Lange

    (@nielslange)

    Apologies for my delayed response, @kcharity. The previous days I was constantly on the road to gather material for the house I’m building with my wife. Pretty stressful. ??</img>

    So to my first point, what should I look for with the template not being overridden? And secondly, do you plan on ever moving over to a?button?vs.?input?

    Allow me to answer both question within one reply. Using the SMNTCS Quantity Increment Buttons for WooCommerce?plugin?while ensuring that the template does not get overwritten might be tricky. I could add a toggle so that a user can switch between using inputor buttonelements. However, the plugin would still use the template that comes from the plugin. If you want to add an SVG, you’d have to fetch the corresponding element on your end using JS and inject that desired SVG. Would that be a solution for you? If so, would you mind sharing the theme and child-theme with me so that I can adjust the plugin accordingly and test it against buttonelements?

    Thread Starter designerken

    (@kcharity)

    The previous days I was constantly on the road to gather material for the house I’m building with my wife. Pretty stressful.

    I totally get it, I am doing a bathroom remodel for my wife and while not as stressful as building a whole house, it can be challenging.

    I could add a toggle so that a user can switch between using input or button elements.

    I think this could be a nice feature to add to your plug-in.

    Would you mind sharing the theme and child-theme with me so that I can adjust the plugin accordingly and test it against button elements?

    Sure, it is a premium theme, so I would have to email it to you, provide me with that I can send it over.

    Back to my main issue…

    What I would really like to diagnose is that the template I have added is not being recognized. As a test, I made edits to the plug-in directly (again just a test, I know that updating the plug-in is not the correct way) and it did make changes to the front-end.

    I have added the template using this structure:

    themes > child-theme > woocommerce > global >  quantity-input.php
    However this doesn’t modify anything on the front end.

    As a second test in your plug-in folder I changed your file name to template > global > quantity-input-disabled.php

    This allowed the template override file I added to then be visible on the front end.

    • This reply was modified 1 year, 11 months ago by designerken. Reason: added file name change section
    Plugin Author Niels Lange

    (@nielslange)

    I totally get it, I am doing a bathroom remodel for my wife and while not as stressful as building a whole house, it can be challenging.

    Suddenly, you have to think about things you never thought about before. But as stressful as it is, I’m sure it’s also very rewarding for both of us. ??</img>

    I think this could be a nice feature to add to your plug-in.

    I couldn’t agree more! I thought about this for the past two days, and today I went ahead and adjusted the template in a way that a user can decide whether to use the default <input type="button"> element or the <button> element.

    Release 2.2 allows you to add the following filter to your site:

    add_filter( 'use_html_buttons', '__return_true' );

    You mentioned that you’re creating a child theme. So in your case, you can simply add this code to the functions.php of your child theme. You might have to do some JS magic to inject the desired icons into the <button> element. But at least, there is a <button> element that you can manipulate.

    Thanks again for suggesting this improvement, and I’d be happy receiving a review of the plugin from you. ??

    Thread Starter designerken

    (@kcharity)

    Release 2.2 allows you to add the following filter to your site:

    add_filter( 'use_html_buttons', '__return_true' );

    This works great, I will test out the ability to change/add icons to the buttons.

    I am still having issues with the Child Theme recognizing the template override. It simply is not using the quantity-input.php file.

    Can you verify that it works for you in a child theme? I am simply adding additional classes to your minus and plus buttons but they do not appear on the front end.

    <?php if ( $flip_quantity_buttons ) : ?>
      <?php if ( $use_html_buttons ) : ?>
        <button class="plus button wp-element-button test-minus">+</button>
        <?php else : ?>
          <input class="plus button wp-element-button test-minus" type="button" value="+">
        <?php endif ?>
      <?php else : ?>
        <?php if ( $use_html_buttons ) : ?>
          <button class="minus button wp-element-button test-minus">-</button>
      <?php else : ?>
          <input class="minus button wp-element-button test-minus" type="button" value="-">
      <?php endif ?>
    <?php endif ?>
Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Template Override not working’ is closed to new replies.