Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/add qty input on product page #1617

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions core/store/modules/product/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,10 @@ const actions: ActionTree<ProductState, RootState> = {
})
}
const setupProduct = (prod) => {
// set product quantity to 1
if(!prod.qty) {
prod.qty = 1
}
// set original product
if (setCurrentProduct) {
context.dispatch('setOriginal', prod)
Expand Down
1 change: 1 addition & 0 deletions core/store/types/product/Product.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,5 @@ export default interface Product {
url_key: string
visibility: number
_score: number
qty: number
}
7 changes: 1 addition & 6 deletions src/themes/default/components/core/ProductBundleOptions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,7 @@ export default {
font-weight: bold;
margin-bottom: 10px;
}
.custom-option > input.qty {
font-weight: bold;
margin-bottom: 10px;
margin: 5px;
width: 20px;
}

.error {
color: $color-error;
padding-top: 5px;
Expand Down
32 changes: 29 additions & 3 deletions src/themes/default/pages/Product.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,17 @@
v-if="product.special_price && product.priceInclTax && product.originalPriceInclTax"
>
<span class="h2 cl-mine-shaft weight-700">
{{ product.priceInclTax | price }}
{{ product.priceInclTax * product.qty | price }}
</span>&nbsp;
<span class="price-original h3">
{{ product.originalPriceInclTax | price }}
{{ product.originalPriceInclTax * product.qty | price }}
</span>
</div>
<div
class="h2 cl-mine-shaft weight-700"
v-if="!product.special_price && product.priceInclTax"
>
{{ product.priceInclTax | price }}
{{ product.priceInclTax * product.qty | price }}
</div>
</div>
<div
Expand Down Expand Up @@ -134,6 +134,19 @@
v-else-if="product.custom_options && product.custom_options.length > 0 && !loading"
:product="product"
/>
<div class="row m0 mb15" v-if="product.type_id !== 'grouped' && product.type_id !== 'bundle'">
<div>
<label class="qty-label flex" for="quantity">{{ $t('Quantity') }}</label>
<input
type="number"
min="0"
class="m0 no-outline qty-input py10 brdr-cl-primary bg-cl-transparent h4"
id="quantity"
focus
v-model="product.qty"
>
</div>
</div>
<div class="row m0">
<add-to-cart
:product="product"
Expand Down Expand Up @@ -440,4 +453,17 @@ $bg-secondary: color(secondary, $colors-background);
mix-blend-mode: multiply;
width: 460px;
}

.qty-input {
border-style: solid;
border-width: 0 0 1px 0;
width: 90px;
}

.qty-label {
margin-bottom: 12px;
cursor: pointer;
font-size: 14px;
}

</style>