Looking for a way to display drop-down deformations on the woocommerce shopping page? In this post, we will share a simple solution for you. However, you will use custom code, so implementing this solution requires some coding experience. Most e-commerce stores have a wide variety of products. Customers must click on a single product page to view variants. Displaying commodity roadblocks on the shop page can capture the hearts of customers. You can also zoom in on the product with just a few clicks. Woocommerce show dropdown variations on shop page after this guide, you can programmatically display the deformation drop-down menu on the store page. However, the first thing to note is that product variants must be created on the product page.
You must also install or create a subtopic before continuing. This ensures that changes are not lost during updates. In addition, if an error occurs, you need to back up your account to restore it to the previous version. I’ll go in and have a look. Steps to display the drop-down deformation drop-down menu on the shopping page. The following are simple steps to follow. Log in to the WordPress site and access the dashboard as an administrator. In the panel menu, click shape Menu > theme editor menu. If the theme editor page opens, please browse the theme function file and add the function of displaying the drop-down conversion on the store page. Add the following code to the PHP file:\/\/ Display variations dropdowns on shop page for variable products
add_filter( ‘woocommerce_loop_add_to_cart_link’, ‘njengah_display_variation_dropdown_on_shop_page’ );
function njengah_display_variation_dropdown_on_shop_page() {
global $product;
if( $product->is_type( ‘variable’ )) {
$attribute_keys = array_keys( $product->get_attributes() );
?>
id ); ?> \
<form class="variations_form cart" method="post" enctype='multipart/form-data' data-product_id="
get_available_variations() ) && false !== $ product->get_available_variations() ) : ?>
|
<label for="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’, ” . __( ‘Clear’, ‘woocommerce’ ) . ‘ ‘ ) : ”; ?> |
%s’,
esc_url( $product->add_to_cart_url() ),
esc_attr( isset( $quantity ) ? $ quantity