• Resolved carver1g

    (@carver1g)


    I have fields cloning enabled and with the default woocommerce quantity selector all works perfectly.
    I am now using a drop down quantity selector but the fields are not being reproduced.
    Here is the code I am using for the selector:

    if ( ! defined( ‘ABSPATH’ ) ) exit; // Exit if accessed directly

    global $product;

    $defaults = array(
    ‘max_value’ => apply_filters( ‘woocommerce_quantity_input_max’, ”, $product ),
    ‘min_value’ => apply_filters( ‘woocommerce_quantity_input_min’, ”, $product ),
    ‘step’ => apply_filters( ‘woocommerce_quantity_input_step’, ‘1’, $product ),
    );

    if ( ! empty( $defaults[‘min_value’] ) )
    $min = $defaults[‘min_value’];
    else $min = 1;

    if ( ! empty( $defaults[‘max_value’] ) )
    $max = $defaults[‘max_value’];
    else $max = 10;

    if ( ! empty( $defaults[‘step’] ) )
    $step = $defaults[‘step’];
    else $step = 1;

    ?>
    <div class=”quantity_select”>
    <select name=”<?php echo esc_attr( $input_name ); ?>” title=”<?php _ex( ‘Qty’, ‘Product quantity input tooltip’, ‘woocommerce’ ) ?>” class=”qty”>
    <?php
    for ( $count = $min; $count <= $max; $count = $count+$step ) {
    if ( $count == $input_value )
    $selected = ‘ selected’;
    else $selected = ”;
    echo ‘<option value=”‘ . $count . ‘”‘ . $selected . ‘>’ . $count . ‘</option>’;
    }
    ?>
    </select>
    </div>

    Was wondering if I could hook into this code with your plugin or if maybe an update in the future would include the use of a drop down selector?

    Thanks

    https://www.ads-software.com/plugins/wc-fields-factory/

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Saravana Kumar K

    (@mycholan)

    Hi,

    The reason is the change event for the quantity field has been registered for the input field.

    update the wc-fields-factory/assets/js/wccpf-front-end.js LN : 25 with the following line.

    $( document ).on( "change", "select.qty", function() {

    Thread Starter carver1g

    (@carver1g)

    Thank you very much. Works absolutely perfect! Sir, you are a genius!

    Hello carver1g!
    Can you guide to me this problem?
    Thank you!

    Thread Starter carver1g

    (@carver1g)

    @qaqeqe0
    What can I help you with?

    Hi there!
    You can guide clone woocommerce quantity, do quantity to quantity dropdown in plugin wc_factory_field.
    Thank you

    Thread Starter carver1g

    (@carver1g)

    This basically what I did. I am using a child theme and created a folder ‘woocommerce’. Inside the ‘woocommerce’ folder I created another folder ‘global’.

    Copy and paste the above code in a text editor and save it as quantity-input.php. Place this file in the global folder you created. This file will replace the default woocommerce quantity selector with a drop down selector.

    Then go to the WC Fields Factory plugin/assets/js/wccpf-front-end.js. Edit the wccpf-front-end.js file by dragging and dropping into a text editor.

    Look for this line “$( document ).on( “change”, “input[name=quantity]”, function() {“, function() {” and change this line to “$( document ).on( “change”, “select.qty”, function() {“.

    Replace “input[name=quantity]” with “select.qty”.

    Hope this helps.

    Thank you very much. Works absolutely perfect!

    • This reply was modified 8 years, 5 months ago by qaqeqe0.
Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Drop down quantity selector’ is closed to new replies.