28
Lecture#05

Product Variations and User Uploads Product and Categories are not enough Needs to extend product information User can customize product information

Embed Size (px)

Citation preview

Page 1: Product Variations and User Uploads  Product and Categories are not enough  Needs to extend product information  User can customize product information

Lecture#05

Page 2: Product Variations and User Uploads  Product and Categories are not enough  Needs to extend product information  User can customize product information

Ouline

Product Variations and User Uploads

Page 3: Product Variations and User Uploads  Product and Categories are not enough  Needs to extend product information  User can customize product information

Our Product View

Page 4: Product Variations and User Uploads  Product and Categories are not enough  Needs to extend product information  User can customize product information

Product Variations and User Uploads

Product and Categories are not enough Needs to extend product information

User can customize product information Product variation, uploading images, or product

text We are focusing on:

How to create customizable products How to assign uploaded files to individual product

orders How we will maintain these uploads How to assign custom user-submitted data with

individual product orders

Page 5: Product Variations and User Uploads  Product and Categories are not enough  Needs to extend product information  User can customize product information

Giving User Choice

So far, we have seen static or non-customizable products in our framework

Many products in e-commerce stores require some sort of choice from the customer Product size, color, no. of items, or material

Why user can customize product information? To see variations of product To choose required variation of product before

purchasing it

Page 6: Product Variations and User Uploads  Product and Categories are not enough  Needs to extend product information  User can customize product information

Simple Variant

We can use a single dropdown box for variations of product

For a T-Shirt product We may have two variants, color and size For both we may have two dropdowns, one for

each To implement this in framework

We would only need to make a reference to the variant of the product the user decides to purchase

In DB, along with product info. of shopping cart, two columns for variant are also required

Page 7: Product Variations and User Uploads  Product and Categories are not enough  Needs to extend product information  User can customize product information

Combinations of Variants

Simple variant like color or size or quite limiting

But with two variants, color and size, admin would need to create a variant for each combination of these

Which wouldn't really be practical For different 5 colors and 5 sizes,

admin may need to handle 25 combinations of variants of a product

Page 8: Product Variations and User Uploads  Product and Categories are not enough  Needs to extend product information  User can customize product information

How will this work?

Our framework work should have a list ofadministrator-definable variation types or attributes

For example for following attributes Size, color Each attribute will be associated with its no. of

variations Size Variants: small, medium, Large, XL, XXL Color Variants: red, green, blue, white, black

Page 9: Product Variations and User Uploads  Product and Categories are not enough  Needs to extend product information  User can customize product information

How will this work?

Each product will have a number of these variations associated with it, grouped by their variation type

We need to store and manage potential cost differences with different versions of a product Large T-Shirt have larger cost than small T-

Shirt

Page 10: Product Variations and User Uploads  Product and Categories are not enough  Needs to extend product information  User can customize product information

High Level Overview

Any combination of variants selected by customer will be the end product to sale

It is quite different than any combination will lead to a separate product

Product

ColorRed

GreenBlue

WhiteBlack

SizeSmall

MediumLarge

XLXXL

Page 11: Product Variations and User Uploads  Product and Categories are not enough  Needs to extend product information  User can customize product information

Database Structure

We won't be associating a product with variation types (attributes) Because all products have not same variation types Mobile and T-Shirt

We need to create two tables to record the variation data itself

Some additional tables to maintain the relationship between products and their variants

Page 12: Product Variations and User Uploads  Product and Categories are not enough  Needs to extend product information  User can customize product information

Database Structure

Field Type Description

ID Integer (Primary Key,Auto Increment)

To reference the attribute from the attribute values table

Name Varchar The name of the attribute, for example size, color, and so on

Product Attributes table

Page 13: Product Variations and User Uploads  Product and Categories are not enough  Needs to extend product information  User can customize product information

Database Structure

Field Type Description

ID Integer (Primary Key,Auto Increment)

To reference the attribute from the association with the products table

Name Varchar The name for the attribute value, for example, Blue, Large, and so on

Attribute_id

Integer The attribute this value is associated with

Product Attribute Values table

Page 14: Product Variations and User Uploads  Product and Categories are not enough  Needs to extend product information  User can customize product information

Database Structure

Field Type Description

Product_id Integer

The ID of the product we are associating with the attribute value

Attribute_value

Integer

The ID of the attribute value the product is being associated with

Order Integer

Determines the order in which the value should be displayed in the attribute list

Cost_difference

Integer

Indicates if the variant product has a cost implication, for example ordering an extra large -Tshirt may increase the cost

Product-Attribute-Value-Association table

Page 15: Product Variations and User Uploads  Product and Categories are not enough  Needs to extend product information  User can customize product information

Database Structure

Product-attribute-value-association table

Page 16: Product Variations and User Uploads  Product and Categories are not enough  Needs to extend product information  User can customize product information

Database Structure

Constraints on Product-attribute-value-association table

Page 17: Product Variations and User Uploads  Product and Categories are not enough  Needs to extend product information  User can customize product information

Template Switching-Before

Page 18: Product Variations and User Uploads  Product and Categories are not enough  Needs to extend product information  User can customize product information

Template Switching-Now

Page 19: Product Variations and User Uploads  Product and Categories are not enough  Needs to extend product information  User can customize product information

Changing Product Query

In order to detect, a product has any variation or changeable attributes We use to get product data and use it for

sub query Sub query groups together all of the

attribute and attribute values associated with a product

Page 20: Product Variations and User Uploads  Product and Categories are not enough  Needs to extend product information  User can customize product information

Switching the Template

Product controller will check the attributes property and call/generate the relevant template Template with or without attributes value

Iterate through them, and for each attributewe generate a list of values associated with it

List is inserted in template (dropdown) dynamically

Attributes are cached and then inserted as tags for template engine

Page 21: Product Variations and User Uploads  Product and Categories are not enough  Needs to extend product information  User can customize product information

Template Switching-Now

Page 22: Product Variations and User Uploads  Product and Categories are not enough  Needs to extend product information  User can customize product information

Another Product View

Page 23: Product Variations and User Uploads  Product and Categories are not enough  Needs to extend product information  User can customize product information

Giving User Controls

Along with choices about a product we may want to give user more controls Uploading a photo to be printed on T-Shirt Short text to be displayed on T-Shirt

For photo Template required a file upload field Can be allowed more than one photos

Custom Text Template requires a textarea or textbox field Also multiple texts can be allowed

Page 24: Product Variations and User Uploads  Product and Categories are not enough  Needs to extend product information  User can customize product information

Giving user Controls

Page 25: Product Variations and User Uploads  Product and Categories are not enough  Needs to extend product information  User can customize product information

Giving User Control- Photo Upload

Maintaining Uploads in two ways If order has been placed

Image is uploaded, payment has made, and order has been completed

Image should be removed from uploads and DB

If order has not been placed Image is uploaded and product is placed in

basket but order is not placed Image should also be removed from uploads

and DB

Page 26: Product Variations and User Uploads  Product and Categories are not enough  Needs to extend product information  User can customize product information

Giving User Control- Photo Upload

Security consideration about uploads Someone can repeatedly upload images▪ CAPTCHA or time delay are useful

Someone can upload abused images What type of images should be uploaded?▪ Provide list of images extensions to controller

What should be the maximum size of each image?▪ Controller should allow to upload up to a fixed size

Prevent customers to find uploads of other customers▪ Privacy policy or authentication can be solution

Page 27: Product Variations and User Uploads  Product and Categories are not enough  Needs to extend product information  User can customize product information

Giving User Control-DB Chnages

We need to add two fields in product table allow_upload(Boolean): is a customer

allowed to upload file for specific product custom_text_inputs(longtext): array of

free text fields collected from our customers.

Page 28: Product Variations and User Uploads  Product and Categories are not enough  Needs to extend product information  User can customize product information

Giving User Control-Template

Template required to show the variations to user if product has customization options Textarea or file upload fields

If no customization options, standard template is enough

It can be done with template switching with product variations If customization allowed, show

customization fileds