Plugin Directory

Changeset 3450888


Ignore:
Timestamp:
01/31/2026 08:26:40 AM (5 weeks ago)
Author:
gravitymaster97
Message:

Description of changes

Location:
display-product-variations-dropdown-on-shop-page-for-woocommerce/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • display-product-variations-dropdown-on-shop-page-for-woocommerce/trunk/display-product-variations-dropdown-on-shop-page-for-woocommerce.php

    r3256293 r3450888  
    11<?php
    22/**
    3  * Plugin Name: display product variations dropdown on shop page For Woocommerce
     3 * Plugin Name: Variations Dropdown On Shop Page For Woocommerce
    44 * Description: Show all different dropdownvariation as single product in shop page and category page
    55 * Version:     1.0
  • display-product-variations-dropdown-on-shop-page-for-woocommerce/trunk/includes/DPVDW_Admin.php

    r3256293 r3450888  
    8989          <?php
    9090          settings_fields( 'dpvdw_options_group' );
    91           $dpvdw_enable_setting = get_option('dpvdw_enable_setting');
     91          $dpvdw_enable_setting = get_option('dpvdw_enable_setting','yes');
    9292
    9393
  • display-product-variations-dropdown-on-shop-page-for-woocommerce/trunk/includes/DPVDW_Frontend.php

    r3274913 r3450888  
    99    public function __construct () {
    1010   
    11         if(get_option('dpvdw_enable_setting')=='yes'){
     11        if(get_option('dpvdw_enable_setting','yes')=='yes'){
    1212
    1313                add_filter( 'woocommerce_loop_add_to_cart_link', array( $this, 'DPVDW_display_variation_dropdown_on_shop_page' ) , 10, 3 );
     
    4646          ?>
    4747
    48           <form class="variations_form cart" method="post" enctype='multipart/form-data' data-product_id="<?php echo absint( $proid ); ?>" data-product_variations="<?php echo htmlspecialchars( json_encode( $product->get_available_variations() ) ) ?>">
    49             <?php do_action( 'woocommerce_before_variations_form' ); ?>
     48         
     49<form class="variations_form cart" method="post" enctype='multipart/form-data' data-product_id="<?php echo absint( $proid ); ?>" data-product_variations="<?php echo htmlspecialchars( json_encode( $product->get_available_variations() ) ) ?>">
     50        <?php do_action( 'woocommerce_before_variations_form' ); ?>
    5051
    51             <?php if ( empty( $product->get_available_variations() ) && false !== $product->get_available_variations() ) : ?>
    52               <p class="stock out-of-stock">
    53                 <?php _e( 'This product is currently out of stock and unavailable.', 'woocommerce' ); ?>
    54               </p>
    55             <?php else : ?>
    56               <table class="variations" cellspacing="0">
    57                 <tbody>
    58                   <?php foreach ( $product->get_variation_attributes() as $attribute_name => $options ) : ?>
    59                   <tr>
    60                     <td class="label"><label for="<?php echo esc_attr(sanitize_title( $attribute_name )); ?>"><?php echo esc_attr(wc_attribute_label( $attribute_name )); ?></label></td>
    61                     <td class="value">
    62                       <?php
    63                         $selected = isset( $_REQUEST[ 'attribute_' . sanitize_title( $attribute_name ) ] ) ? wc_clean( urldecode( $_REQUEST[ 'attribute_' . sanitize_title( $attribute_name ) ] ) ) : $product->get_variation_default_attribute( $attribute_name );
    64                         wc_dropdown_variation_attribute_options( array( 'options' => $options, 'attribute' => $attribute_name, 'product' => $product, 'selected' => $selected ) );
    65                       ?>
    66                     </td>
    67                   </tr>
    68                   <?php endforeach;?>
    69                 </tbody>
    70               </table>
     52        <?php if ( empty( $product->get_available_variations() ) && false !== $product->get_available_variations() ) : ?>
     53          <p class="stock out-of-stock">
     54            <?php _e( 'This product is currently out of stock and unavailable.', 'woocommerce' ); ?>
     55          </p>
     56        <?php else : ?>
     57          <table class="variations" cellspacing="0">
     58            <tbody>
     59              <?php foreach ( $product->get_variation_attributes() as $attribute_name => $options ) : ?>
     60              <tr>
     61                <td class="label"><label for="<?php echo esc_attr(sanitize_title( $attribute_name )); ?>"><?php echo esc_attr(wc_attribute_label( $attribute_name )); ?></label></td>
     62                <td class="value">
     63                  <?php
     64                    $selected = isset( $_REQUEST[ 'attribute_' . sanitize_title( $attribute_name ) ] ) ? wc_clean( urldecode( $_REQUEST[ 'attribute_' . sanitize_title( $attribute_name ) ] ) ) : $product->get_variation_default_attribute( $attribute_name );
     65                    wc_dropdown_variation_attribute_options( array( 'options' => $options, 'attribute' => $attribute_name, 'product' => $product, 'selected' => $selected ) );
     66                  ?>
     67                </td>
     68              </tr>
     69              <?php endforeach;?>
     70            </tbody>
     71          </table>
    7172
    72               <?php do_action( 'woocommerce_before_add_to_cart_button' ); ?>
     73          <?php do_action( 'woocommerce_before_add_to_cart_button' ); ?>
    7374
    74               <div class="single_variation_wrap">
    75                 <?php
    76                   /**
    77                    * woocommerce_before_single_variation Hook.
    78                    */
    79                   do_action( 'woocommerce_before_single_variation' );
     75          <div class="single_variation_wrap">
     76            <?php
     77              /**
     78               * woocommerce_before_single_variation Hook.
     79               */
     80              do_action( 'woocommerce_before_single_variation' );
    8081
    81                   /**
    82                    * woocommerce_single_variation hook. Used to output the cart button and placeholder for variation data.
    83                    * @since 2.4.0
    84                    * @hooked woocommerce_single_variation - 10 Empty div for variation data.
    85                    * @hooked woocommerce_single_variation_add_to_cart_button - 20 Qty and cart button.
    86                    */
    87                   do_action( 'woocommerce_single_variation' );
     82              /**
     83               * woocommerce_single_variation hook. Used to output the cart button and placeholder for variation data.
     84               * @since 2.4.0
     85               * @hooked woocommerce_single_variation - 10 Empty div for variation data.
     86               * @hooked woocommerce_single_variation_add_to_cart_button - 20 Qty and cart button.
     87               */
     88              do_action( 'woocommerce_single_variation' );
    8889
    89                   /**
    90                    * woocommerce_after_single_variation Hook.
    91                    */
    92                   do_action( 'woocommerce_after_single_variation' );
    93                 ?>
    94               </div>
     90              /**
     91               * woocommerce_after_single_variation Hook.
     92               */
     93              do_action( 'woocommerce_after_single_variation' );
     94            ?>
     95          </div>
    9596
    96               <?php do_action( 'woocommerce_after_add_to_cart_button' ); ?>
    97              
    98             <?php endif; ?>
     97          <?php do_action( 'woocommerce_after_add_to_cart_button' ); ?>
    9998
    100             <?php do_action( 'woocommerce_after_variations_form' ); ?>
    101            
    102           </form>
     99        <?php endif; ?>
     100
     101        <?php do_action( 'woocommerce_after_variations_form' ); ?>
     102
     103      </form>
    103104
    104105          <?php } else {
  • display-product-variations-dropdown-on-shop-page-for-woocommerce/trunk/readme.txt

    r3428914 r3450888  
    11=== Variations Dropdown On Shop Page For Woocommerce ===
    2 Tested up to: 6.9
     2Tested up to: 6.7.2
    33Stable tag: 1.0
    44License: GPLv2 or later
Note: See TracChangeset for help on using the changeset viewer.