Hey Community!
Okay so I have screenprinting business and trying to advance my website!
I have created a data collection for my printing prices without the cost of the garment
of colors | 12 Shirts | 24 Shirts | etc
One Color | $4.00 | $3.00 | etc
And then I have created another data collection of all the garments I offer at my shop
Shirt Name | Description | Price of Garment
GildanG200 | Some kind of Description | $2.13
now i would like to make a new data collection for the total cost of the garment and the cost for printing by adding 12 shirt QTY @ one color printing + Price of the garment how can I do this?
I want to do this because if down the line i want to update my printing prices this will update all the garments final printing price without having to go in and change every single database collection for each product
You can just add Wix Stores if you are wanting to sell items.
See this section for lots of info about Wix Stores:
https://support.wix.com/en/wix-stores/setting-up-your-store
Or what you can do with Wix Stores and Wix Corvid (code):
https://support.wix.com/en/corvid-by-wix/wix-stores-with-corvid
If you use this forum and click on ‘Documentation’ at the top and then ‘Examples’, you will be given a lot more different examples of code tutorials to use with Wix Stores and payments etc.
https://www.wix.com/corvid/examples
Simple code sample for you.
THE ELEMENTS
The Page
User Input: #quantity
Text Elements:
Unit Price: #UnitPrice
Total Price: #FinalPrice
THE CODE
Page Code
export function quantity_change(event, $w) {
let price = Number($w('#UnitPrice').text);
let selectedQuantity = Number(event.target.value);
$w('#FinalPrice').text = String(selectedQuantity * price);
}
Another simple code example for you.
THE ELEMENTS
The Page
User Input:
Quantity For Product 1:#quantity1
Quantity For Product 2:#quantity2
Text Elements:
Unit Price For Product 1: #UnitPrice1
Unit Price For Product 2: #UnitPrice2
Final Price For Product 1:#FinalPrice1
Final Price For Product 2:#FinalPrice2
Total Price: #TotalPrice
THE CODE
Page Code
export function quantity1_change(event, $w) {
let price = Number($w('#UnitPrice1').text);
let selectedQuantity = Number(event.target.value);
$w('#FinalPrice1').text = String(selectedQuantity * price);
$w('#TotalPrice').text = String(Number($w('#FinalPrice1').text) + Number($w('#FinalPrice2').text));
}
export function quantity2_change(event, $w) {
let price = Number($w('#UnitPrice2').text);
let selectedQuantity = Number(event.target.value);
$w('#FinalPrice2').text = String(selectedQuantity * price);
$w('#TotalPrice').text = String(Number($w('#FinalPrice1').text) + Number($w('#FinalPrice2').text));
}
Thank you for all that information but I’m not trying to sell anything on my site I’m just trying to show information on the cost to complete work for my customer.
So what id love to have is
data collection 1: Screenprinting prices.
Lets say cell B2 has a price of $2 - that will be the cost of printing
data collection 2: All garments i offer etc let’s say cell D6 has a price of $2.80
data collection 3: I want this table to calculate B2 from data collection 1 + D6 from data collection 2 = $4.80
id like This because if I ever update the prices In data collection 1 it will update all other data collections that use data from that table And will update all values
If you are wanting to simply display things like in a excel or Google Sheet kind of way then you can simply add a table master to display price options in.
https://support.wix.com/en/apps-made-by-wix/table-master
Or you can just simply connect your dataset 1 and 2 to dropdowns or radio buttons for example and use the datasets as lists, then the user can choose whichever option they want and all you have to do then is to calculate the first value with the second value to get your final total, which is shown in the code examples above already - $w(‘#FinalPrice’).text = String(selectedQuantity * price);
https://support.wix.com/en/article/working-with-the-connect-dropdown-panel#connect-a-list
https://support.wix.com/en/article/setting-labels-and-values-for-radio-buttons-and-dropdown-lists
For calculation info look here.
https://www.w3schools.com/js/js_arithmetic.asp
Have a read of working with al the user inputs.
https://support.wix.com/en/article/working-with-user-input-elements-9560341
You can also connect your data to a table.
https://support.wix.com/en/article/working-with-the-connect-table-panel
You can filter your data by dropdown checkboxes or dropdown elements.
https://www.wix.com/corvid/example/checkbox-dropdown
https://support.wix.com/en/article/corvid-tutorial-adding-collection-data-search-functionality#search-using-a-dropdown-element-1
For future reference you could always do something like this if you want to expand from just doing prices and you want to show off different items etc.
THE ELEMENTS
The Page
Text Element:
Menu Items: #titles
Total Price (Sum Total of All Items): #TotalPrice
Repeater Elements:
Item Name: #ItemName
Unit Price: #UnitPrice
Quantity Ordered: #quantity
Total Price of Each Item (#UnitPrice X #quantity): #price
Button Element: #CheckOut
The Database
Create a database OrderForm(dataset1) with the same fields as your form.
Database fields
Item Name: ItemName
Quantity Ordered: quantity
Unit Price of Each Item: unitprice
Total Price (Unit Price X quantity): price
THE CODE
Page Code
import wixData from 'wix-data';
function ProductFilter() {
wixData.query("Products")
.eq("heels", $w("#checkbox1").checked)
.or(
wixData.query("Products")
.eq("boots", $w("#checkbox2").checked)
)
.or(
wixData.query("Products")
.eq("sneakers", $w("#checkbox3").checked)
)
// add or statements for the other checkboxes
.find()
.then((results) => {
console.log(results.items);
let Product = results.items;
$w('#repeater1').data = Product;
})
.catch((err) => {
let errorMsg = err;
console.log(errorMsg);
});
}
$w.onReady(function () {
ProductFilter();
$w('#repeater1').onItemReady(($w, itemData) => {
// Add here all the relevant elements of the repeater
$w('#text1').text = itemData.name;
$w('#text2').text = itemData.description;
$w('#text3').text = String(itemData.price);
$w('#image1').src = itemData.image;
});
});
export function checkbox1_change(event) {
ProductFilter();
}
export function checkbox2_change(event) {
ProductFilter();
}
export function checkbox3_change(event) {
ProductFilter();
}
Finally, if you are wanting to do something like this too for order summary before checkout.
Design your checkout page with text elements, a Wix Repeater and a Checkout button, then create a dataset that links to your order form. Link your repeater to the order dataset and add Wix Code for the sum total calculations. So, when customers view their checkout page, they will be able to see the total price of their shopping basket.
THE ELEMENTS
The Page
Text Element:
Menu Items: #titles
Total Price (Sum Total of All Items): #TotalPrice
Repeater Elements:
Item Name: #ItemName
Unit Price: #UnitPrice
Quantity Ordered: #quantity
Total Price of Each Item (#UnitPrice X #quantity): #price
Button Element: #CheckOut
The Database
Create a database OrderForm (dataset1) with the same fields as your form.
Database fields
Item Name: ItemName
Quantity Ordered: quantity
Unit Price of Each Item: unitprice
Total Price (Unit Price X quantity): price
THE CODE
Page Code
$w.onReady(function () {
let count = $w("#dataset1").getTotalCount(); // No. of items in dataset //
$w("#dataset1").getItems(0, count) // Get all items //
.then((results) => {
let sumTotal = 0;
let items = results.items;
items.forEach(item => {
sumTotal = sumTotal + Number(item.price);
});
$w("#total").text = "" + sumTotal;
// Add other calculations here //
}).catch((err) => {
console.log(err);
});
});
hm yeah all of that is really cool but iam looking for something a little different!