• I want to edit the variable products form to hide certain attributes in the product options dropdowns based on User role. A similar question was asked on Stackexchange, but the one answer seems to have off formatting. It’s the general idea I’d like to go for though. http://stackoverflow.com/questions/29406947/woocommerce-product-variation-based-on-user-role

    Below is the portion of code I need to edit, but I’m still not that great at php, so I’m not sure how to go about inserting the necessary conditions. How could I go about doing this?

    <table class="variations" cellspacing="0">
    	<tbody>
    	<?php foreach ( $attributes as $attribute_name => $options ) : ?>
    		<tr>
    		<td class="label"><label for="<?php echo sanitize_title( $attribute_name ); ?>"><?php echo wc_attribute_label( $attribute_name ); ?></label></td>
    		<td class="value">
    			<?php
    			$selected = isset( $_REQUEST[ 'attribute_' . sanitize_title( $attribute_name ) ] ) ? wc_clean( urldecode( $_REQUEST[ 'attribute_' . sanitize_title( $attribute_name ) ] ) ) : $product->get_variation_default_attribute( $attribute_name );
    								wc_dropdown_variation_attribute_options( array( 'options' => $options, 'attribute' => $attribute_name, 'product' => $product, 'selected' => $selected ) );
    			echo end( $attribute_keys ) === $attribute_name ? apply_filters( 'woocommerce_reset_variations_link', '<a class="reset_variations" href="#">' . __( 'Clear', 'woocommerce' ) . '</a>' ) : '';
    
    		        ?>
    		</td>
    		</tr>
    	<?php endforeach;?>
    	</tbody>
    </table>
    • This topic was modified 9 years, 5 months ago by isk2009.

The topic ‘Edit variable.php to show product attributes by user role’ is closed to new replies.