• Resolved gjv

    (@garethjohnvaughan)


    I’ve got a set of variable products which can’t be purchased based on their attributes. I am using a plugin that lets me choose the attribute assigned to the product to do this and works (Country Based Restrictions for WooCommerce). I setup a ‘hidden’ attribute for this purpose.

    I therefore wanted to hide this attribute from appearing on the product page itself. I have used the ‘Visible on the product page’ checkbox, but this only hides in the product information/tabs panel, it doesn’t stop the variation dropdown from appearing on the page.

    I’ve tried a variety of hooks in .php to try and hide the row associated with the variation with no luck. There is no .css applied to the ‘label for’, so I can’t do it that way either, only on the dropdown itself.

    <tr>
    <td class=”label”><label for=”pa_stamped-or-hallmarked”>Stamped or Hallmarked</label></td>
    <td class=”value”>
    <select id=”pa_stamped-or-hallmarked” class=”” name=”attribute_pa_stamped-or-hallmarked” data-attribute_name=”attribute_pa_stamped-or-hallmarked” data-show_option_none=”yes”><option value=””>Choose an option</option><option value=”hallmarked” class=”attached” disabled=””>Hallmarked</option></select>Clear </td>
    </tr>

    Is it even possible?

Viewing 1 replies (of 1 total)
  • Thread Starter gjv

    (@garethjohnvaughan)

    I have found a solution:

    Take a copy of the file ‘woocommerce\templates\single-product\add-to-cart\variable.php’ and add new code (in bold) after line 36:

    <?php foreach ( $attributes as $attribute_name => $options ) : ?>
    <?php if ( $attribute_name != “pa_ATTRIBUTENAME”) { ?>
    … do dropdown ….
    <?php } ?>

    <?php endforeach; ?>

Viewing 1 replies (of 1 total)
  • The topic ‘Attributes Dropdown / Visible on the product page’ is closed to new replies.