• Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Register
  • Login
Bagisto Forum

Bagisto

  • Register
  • Login
  • Search
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups

Add products in cart with numeric value

General Discussion
1
2
125
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L
    LilD last edited by 17 May 2021, 13:16

    How can I add products in cart with numeric value? From example cart page

    1 Reply Last reply Reply Quote 0
    • L
      LilD last edited by 17 May 2021, 17:19

      
                  data: function() {
                      return {
                          qty: this.quantity
                      }
                  },
      
                  watch: {
                      quantity: function (val) {
                          this.qty = val;
      
                          this.$emit('onQtyUpdated', this.qty)
      
                          console.log(this.qty)
                      }
                  },
      
                  methods: {
                      decreaseQty: function() {
                          if (this.qty > this.minQuantity)
                              this.qty = parseInt(this.qty) - 1;
      
                          this.$emit('onQtyUpdated', this.qty)
      
                          console.log(this.qty)
                      },
      
                      increaseQty: function() {
                          this.qty = parseInt(this.qty) + 1;
      
                          this.$emit('onQtyUpdated', this.qty)
      
                          console.log(this.qty)
                      }
                  }
      

      For example, how could I make these values receive the data I type from the keyboard?

      <script type="text/x-template" id="quantity-changer-template">
          <div :class="`quantity control-group ${errors.has(controlName) ? 'has-error' : ''}`">
              <label class="required">{{ __('shop::app.products.quantity') }}</label>
              <button type="button" class="decrease" @click="decreaseQty()">-</button>
      
              <input
                  :value="qty"
                  class="control"
                  :name="controlName"
                  :v-validate="validations"
                  data-vv-as="&quot;{{ __('shop::app.products.quantity') }}&quot;"
                  />
      
              <button type="button" class="increase" @click="increaseQty()">+</button>
      
              <span class="control-error" v-if="errors.has(controlName)">@{{ errors.first(controlName) }}</span>
          </div>
      </script>
      
      
      

      Without :value=qty can send data from keyboard but increase and decrease.. will not work

      1 Reply Last reply Reply Quote 0
      1 out of 2
      • First post
        1/2
        Last post