Home Forums Theme Support Dokan Default 1 in stock?

This topic is: resolved

This topic contains 4 replies, has 4 voices, and was last updated by  Sk 5 years ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #18600

    Jay
    Member
    Post count: 157

    Is there a way to have the default stock show 1? Everyone is at least selling 1 item and I am not sure the stock management would cause any issues. If someone is listing a product, then of course they have at least one to sell. It seems having having 1 listed as default would be safe. just a thought.

    #18602

    Nizam Uddin
    Keymaster
    Post count: 670

    Hello Jay
    Maybe this article can help you http://www.skyverge.com/blog/set-default-stock-quantity-woocommerce-variations/
    Thank you

    #18603

    Rachelle
    Member
    Post count: 54

    I downloaded the plugin WooCommerce Sold Individually and it set all my items in my store as individually sold items. Since that wasn't an option in my csv importer I would have had to manually change every listing. I'm not sure if that is what you are looking for but it worked great for me! ๐Ÿ™‚

    #18604

    Jay
    Member
    Post count: 157

    I added the code below and it did not add 1 in the stock quantity. I added it to the dokan theme-functions.php.

    add_action( ‘admin_enqueue_scripts', ‘wc_default_variation_stock_quantity' );

    function wc_default_variation_stock_quantity() {
    global $pagenow, $woocommerce;

    $default_stock_quantity = 1;
    $screen = get_current_screen();

    if ( ( $pagenow == ‘post-new.php' || $pagenow == ‘post.php' || $pagenow == ‘edit.php' ) && $screen->post_type == ‘product' ) {

    ob_start();
    ?>
    if ( ” === $( ‘#_stock' ).val() ) {
    $( ‘#_stock' ).val(< ?php echo $default_stock_quantity; ?>);
    }
    < ?php $javascript = ob_get_clean(); $woocommerce->add_inline_js( $javascript );
    }
    }

    #18655

    Sk
    Moderator
    Post count: 371

    Hello Jay,

    please navigate to dokan/templates/edit/inventory.php at line 19.

    replace the line
    <?php dokan_post_input_box( $post->ID, '_stock', array( 'placeholder' => '10' ) ); ?>

    with
    <?php dokan_post_input_box( $post->ID, '_stock', array( 'value' => 1 ) ); ?>

    you will get default stock quantity 1 for every new product.

    Thank you

Viewing 5 posts - 1 through 5 (of 5 total)

The topic ‘Default 1 in stock?’ is closed to new replies.