• muhammadzaid

    (@muhammadzaid)


    Hi there,
    I am creating my first onine shop.
    I am facing a problem in displaying custom message for quantity validation.
    Stock quantity is not showing in product detail page but it is showing in cart page. I have share both pages screenshot below.
    Product Detail: https://prntscr.com/93ajnj
    Cart: https://prntscr.com/93ajuk

    I have use below code in woocommerce>single-product>add-to-cart>variable.php

    <?php foreach ( $attributes as $attribute_name => $
    <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( $_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 ? '<a class="reset_variations" href="#">' . __( 'Clear selection', 'woocommerce' ) . '</a>' : ''; ?>
       </td>
    </tr>
    <?php $variations_ob = ob_get_clean(); $variations_arr[wc_attribute_label($attribute_name)] = $variations_ob; endforeach;
    foreach ($variations_arr as $name => $ob) { echo str_ireplace('Choose an option', 'Select '.$name, $ob );
    } ?>

    Any help in this regards will be highly appreciated. Thanks in advance.

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

    (@muhammadzaid)

    My bad, pasted wrong code

    <div class="quantity"><strong>Quantity </strong><input type="number" step="<?php echo esc_attr( $step ); ?>" <?php if ( is_numeric( $min_value ) ) : ?>min="<?php echo esc_attr( $min_value ); ?>"<?php endif; ?> <?php if ( is_numeric( $max_value ) ) : ?>max="<?php echo esc_attr( $max_value ); ?>"<?php endif; ?> name="<?php echo esc_attr( $input_name ); ?>" value="<?php echo esc_attr( $input_value ); ?>" class="input-text qty text" size="4" oninvalid="setCustomValidity('Sorry! we have only <?php echo esc_attr( $max_value ); ?> shirts in your selected size.')"
        onchange="try{setCustomValidity('')}catch(e){}" /></div>
Viewing 1 replies (of 1 total)
  • The topic ‘Change text of quantity HTML5 validation.’ is closed to new replies.