Restructure pages for permutations and basket with metadata for is_included_VAT, id_currency, id_region_delivery
This commit is contained in:
Binary file not shown.
Binary file not shown.
58
app.py
58
app.py
@@ -112,7 +112,7 @@ def contact():
|
||||
|
||||
|
||||
# Store
|
||||
@app.route('/store', methods=['GET'])
|
||||
@app.route('/store', methods=['GET', 'POST'])
|
||||
def store_home():
|
||||
print("store home")
|
||||
try:
|
||||
@@ -120,17 +120,20 @@ def store_home():
|
||||
except:
|
||||
data = {}
|
||||
print(f'data={data}')
|
||||
"""
|
||||
try:
|
||||
id_currency = data.id_currency
|
||||
except:
|
||||
id_currency = Model_View_Store.ID_CURRENCY_DEFAULT
|
||||
print(f"id_currency = {id_currency}")
|
||||
try:
|
||||
id_region_delivery = data.id_region_delivery
|
||||
except:
|
||||
id_region_delivery = Model_View_Store.ID_REGION_DELIVERY_DEFAULT
|
||||
"""
|
||||
id_currency, id_region_delivery, is_included_VAT = DataStore_Store.get_metadata_basket(data)
|
||||
print(f"id_currency = {id_currency}")
|
||||
print(f"id_region_delivery = {id_region_delivery}")
|
||||
model = Model_View_Store_Home(db, get_info_user(), app, id_currency, id_region_delivery)
|
||||
model = Model_View_Store_Home(db, get_info_user(), app, id_currency, id_region_delivery, is_included_VAT)
|
||||
# model.get_regions_and_currencies()
|
||||
# model.categories = Model_View_Store_Home.get_many_product_category(db)
|
||||
# product = categories[list(categories.keys())[0]][0]
|
||||
@@ -163,9 +166,12 @@ def store_home():
|
||||
for p in cat.products:
|
||||
print(f'product: {p.name}')
|
||||
print(f'selected permutation: {p.get_permutation_selected()}')
|
||||
return render_template('_page_store_home.html', model = model) # "<html><body><h1>Boobs</h1></html></body>"
|
||||
# POST request
|
||||
# return jsonify(Success=True, data={'html_block': render_template('_page_store_home.html', model = model)})
|
||||
if request.method == 'GET':
|
||||
return render_template('_page_store_home.html', model = model) # "<html><body><h1>Boobs</h1></html></body>"
|
||||
else: # POST request
|
||||
html_block = render_template('_block_store_home_body.html', model = model)
|
||||
print(f'html_block:\n{html_block}')
|
||||
return jsonify(Success=True, data={'html_block': html_block})
|
||||
|
||||
# update with local basket, if not logged in- partial
|
||||
@app.route('/store/basket_load', methods=['POST'])
|
||||
@@ -176,11 +182,11 @@ def basket_load():
|
||||
print(f'data={data}')
|
||||
|
||||
# model, html_block = render_basket_from_JSON(data)
|
||||
id_currency, id_region_delivery, is_included_VAT = DataStore_Store.get_metadata_basket(data)
|
||||
model = Model_View_Store_Home(db, get_info_user(), app, id_currency, id_region_delivery)
|
||||
id_currency, id_region_delivery, is_included_VAT = DataStore_Store.get_metadata_basket(data) # , Model_View_Store.KEY_BASKET)
|
||||
model = Model_View_Store_Home(db, get_info_user(), app, id_currency, id_region_delivery, is_included_VAT)
|
||||
# model.import_JSON_basket(data)
|
||||
model.get_basket(data)
|
||||
model.is_included_VAT = is_included_VAT
|
||||
# model.is_included_VAT = is_included_VAT
|
||||
|
||||
html_block = render_template('_block_store_basket.html', model = model)
|
||||
print(f'html_block:\n{html_block}')
|
||||
@@ -192,9 +198,15 @@ def basket_add():
|
||||
data = request.json # .get('data')
|
||||
print(f'data: {data}')
|
||||
id_currency, id_region_delivery, is_included_VAT = DataStore_Store.get_metadata_basket(data)
|
||||
model = Model_View_Store_Home(db, get_info_user(), app, id_currency, id_region_delivery)
|
||||
model.is_included_VAT = is_included_VAT
|
||||
model = Model_View_Store_Home(db, get_info_user(), app, id_currency, id_region_delivery, is_included_VAT)
|
||||
# model.is_included_VAT = is_included_VAT
|
||||
form_data = data[Model_View_Store.key_form]
|
||||
"""
|
||||
try:
|
||||
form_data[Model_View_Store.KEY_VALUE_DEFAULT]
|
||||
except KeyError:
|
||||
form_data[Model_View_Store.KEY_VALUE_DEFAULT] =
|
||||
"""
|
||||
print(f'form_data: {form_data}')
|
||||
form = Form_Basket_Add(**form_data)
|
||||
print('form acquired')
|
||||
@@ -227,7 +239,7 @@ def basket_edit():
|
||||
data = request.json # .get('data')
|
||||
print(f'data: {data}')
|
||||
id_currency, id_region_delivery, is_included_VAT = DataStore_Store.get_metadata_basket(data)
|
||||
model = Model_View_Store_Home(db, get_info_user(), app, id_currency, id_region_delivery)
|
||||
model = Model_View_Store_Home(db, get_info_user(), app, id_currency, id_region_delivery, is_included_VAT)
|
||||
model.is_included_VAT = is_included_VAT
|
||||
form_data = data[Model_View_Store.key_form]
|
||||
print(f'form_data: {form_data}')
|
||||
@@ -258,7 +270,7 @@ def basket_delete():
|
||||
data = request.json # .get('data')
|
||||
print(f'data: {data}')
|
||||
id_currency, id_region_delivery, is_included_VAT = DataStore_Store.get_metadata_basket(data)
|
||||
model = Model_View_Store_Home(db, get_info_user(), app, id_currency, id_region_delivery)
|
||||
model = Model_View_Store_Home(db, get_info_user(), app, id_currency, id_region_delivery, is_included_VAT)
|
||||
model.is_included_VAT = is_included_VAT
|
||||
try:
|
||||
# print('importing basket')
|
||||
@@ -292,7 +304,7 @@ def store_basket():
|
||||
try:
|
||||
data = request.json
|
||||
id_currency, id_region_delivery, is_included_VAT = DataStore_Store.get_metadata_basket(data)
|
||||
model = Model_View_Store_Basket(db, get_info_user(), app, id_currency, id_region_delivery)
|
||||
model = Model_View_Store_Basket(db, get_info_user(), app, id_currency, id_region_delivery, is_included_VAT)
|
||||
model.is_included_VAT = is_included_VAT
|
||||
except:
|
||||
raise Exception('Bad data received by controller')
|
||||
@@ -316,7 +328,8 @@ def basket_info():
|
||||
_m = 'basket_info'
|
||||
data = request.json # .get('data')
|
||||
print(f'data: {data}')
|
||||
model = Model_View_Store_Basket(db, get_info_user(), app)
|
||||
id_currency, id_region_delivery, is_included_VAT = DataStore_Store.get_metadata_basket(data)
|
||||
model = Model_View_Store_Basket(db, get_info_user(), app, id_currency, id_region_delivery, is_included_VAT)
|
||||
form_data = data[Model_View_Store.key_form]
|
||||
print(f'form_data: {form_data}')
|
||||
form = Form_Billing(**form_data)
|
||||
@@ -360,8 +373,8 @@ def basket_info():
|
||||
return jsonify({'status': 'failure', 'Message': f'Invalid address information\n{form.errors}'})
|
||||
|
||||
|
||||
@app.route('/store/product?permutationId=<permutation_id>regionId=&<region_id>¤cyId=<currency_id>', methods=['GET']) # <product_id>&
|
||||
def store_product(permutation_id, region_id, currency_id):
|
||||
@app.route('/store/product?permutationId=<permutation_id>regionId=&<region_id>¤cyId=<currency_id>&isIncludedVAT=<is_included_VAT>', methods=['GET']) # <product_id>&
|
||||
def store_product(permutation_id, region_id, currency_id, is_included_VAT):
|
||||
_m = 'store_product'
|
||||
"""
|
||||
av.full_val_int(product_id, 'product_id', _m)
|
||||
@@ -379,7 +392,7 @@ def store_product(permutation_id, region_id, currency_id):
|
||||
# print(f'product id: {product_id}')
|
||||
print(f'permutation id: {permutation_id}')
|
||||
try:
|
||||
model = Model_View_Store_Product(db, get_info_user(), app, permutation_id, currency_id, region_id)
|
||||
model = Model_View_Store_Product(db, get_info_user(), app, permutation_id, currency_id, region_id, is_included_VAT)
|
||||
print('model reached')
|
||||
# model.id_currency, model.id_region_delivery, model.is_included_VAT = DataStore_Store.get_metadata_basket(request.json)
|
||||
# model.get_many_product_category(product_ids = str(product_id))
|
||||
@@ -451,7 +464,8 @@ def get_checkout_session(session_id):
|
||||
def create_checkout_session():
|
||||
# quantity = request.form.get('quantity', 1)
|
||||
# domain_url = os.getenv('DOMAIN')
|
||||
model = Model_View_Store_Checkout(db, get_info_user(), app)
|
||||
id_currency, id_region_delivery, is_included_VAT = DataStore_Store.get_metadata_basket(data)
|
||||
model = Model_View_Store_Checkout(db, get_info_user(), app, id_currency, id_region_delivery, is_included_VAT)
|
||||
print('checkout model created')
|
||||
try:
|
||||
data = request.json # .get('data')
|
||||
@@ -561,9 +575,9 @@ def set_delivery_region():
|
||||
if form.validate_on_submit():
|
||||
app.id_region_delivery = form.id_region_delivery.data
|
||||
"""
|
||||
app.id_region_delivery = form_data[Model_View_Base.KEY_ID_REGION_DELIVERY]
|
||||
print(f'id_region_delivery: {app.id_region_delivery}')
|
||||
return jsonify(Success=True, data={Model_View_Base.KEY_ID_REGION_DELIVERY: app.id_region_delivery})
|
||||
id_region_delivery = form_data[Model_View_Store.KEY_BASKET][Model_View_Base.KEY_ID_REGION_DELIVERY]
|
||||
print(f'id_region_delivery: {id_region_delivery}')
|
||||
return jsonify(Success=True, data={Model_View_Base.KEY_ID_REGION_DELIVERY: id_region_delivery})
|
||||
|
||||
# currency
|
||||
@app.route('/store/set_currency', methods=['POST'])
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -108,9 +108,21 @@ class Basket_Item():
|
||||
'''
|
||||
|
||||
class Basket():
|
||||
KEY_BASKET: str = 'basket'
|
||||
KEY_ID_CURRENCY: str = 'id_currency'
|
||||
KEY_ID_REGION_DELIVERY: str = 'id_region_delivery'
|
||||
KEY_IS_INCLUDED_VAT: str = 'is_included_VAT'
|
||||
KEY_ITEMS: str = 'items'
|
||||
items: list
|
||||
def __init__(self):
|
||||
is_included_VAT: bool
|
||||
id_region_delivery: int
|
||||
id_currency: int
|
||||
|
||||
def __init__(self, is_included_VAT, id_currency, id_region_delivery):
|
||||
self.items = []
|
||||
self.is_included_VAT = is_included_VAT
|
||||
self.id_currency = id_currency
|
||||
self.id_region_delivery = id_region_delivery
|
||||
def add_item(self, item):
|
||||
av.val_instance(item, 'item', 'Basket.add_item', Basket_Item)
|
||||
self.items.append(item)
|
||||
@@ -134,7 +146,12 @@ class Basket():
|
||||
json_list.append(item.to_json())
|
||||
return json_list
|
||||
def to_json(self):
|
||||
return {'items': self.to_json_list()}
|
||||
return {
|
||||
Basket.KEY_ITEMS: self.to_json_list(),
|
||||
Basket.KEY_IS_INCLUDED_VAT: self.is_included_VAT,
|
||||
Basket.KEY_ID_CURRENCY: self.id_currency,
|
||||
Basket.KEY_ID_REGION_DELIVERY: self.id_region_delivery
|
||||
}
|
||||
def output_total(self):
|
||||
sum = 0
|
||||
for b_i in self.items:
|
||||
|
||||
@@ -184,6 +184,14 @@ class Category(db.Model):
|
||||
if not (len(self.products) == 0):
|
||||
print(f'getting first permutation from product')
|
||||
return None if len(self.products) == 0 else self.products[0].get_permutation_selected()
|
||||
|
||||
def is_available(self):
|
||||
if len(self.products) == 0:
|
||||
return False
|
||||
for product in self.products:
|
||||
if product.is_available():
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
class Product_Category_Filters():
|
||||
|
||||
@@ -317,6 +317,15 @@ class Product(db.Model):
|
||||
av.val_instance(discount, 'discount', 'Product.add_discount', Discount)
|
||||
index_permutation = self.permutation_index[discount.id_permutation] # self.get_index_permutation_from_id(discount.id_permutation)
|
||||
self.permutations[index_permutation].add_discount(discount)
|
||||
def has_permutations(self):
|
||||
return len(self.permutations) > 0
|
||||
def is_available(self):
|
||||
if len(self.permutations) == 0:
|
||||
return False
|
||||
for permutation in self.permutations:
|
||||
if permutation.is_available():
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
class Product_Permutation(db.Model):
|
||||
@@ -362,7 +371,7 @@ class Product_Permutation(db.Model):
|
||||
self.form_basket_add = Form_Basket_Add()
|
||||
self.form_basket_edit = Form_Basket_Edit()
|
||||
self.is_unavailable_in_currency_or_region = False
|
||||
self.is_available = True
|
||||
# self.is_available = False
|
||||
|
||||
def make_from_DB_product(query_row):
|
||||
_m = 'Product_Permutation.make_from_DB_product'
|
||||
@@ -422,6 +431,8 @@ class Product_Permutation(db.Model):
|
||||
permutation.id_permutation = json_basket_item[key_id_permutation]
|
||||
return permutation
|
||||
|
||||
def is_available(self):
|
||||
return len(self.prices) > 0
|
||||
def get_price(self):
|
||||
return self.prices[0]
|
||||
def get_price_local_VAT_incl(self):
|
||||
|
||||
Binary file not shown.
@@ -43,9 +43,10 @@ import os
|
||||
|
||||
# CLASSES
|
||||
class DataStore_Store():
|
||||
KEY_IS_INCLUDED_VAT = 'is_included_VAT'
|
||||
KEY_ID_CURRENCY = 'id_currency'
|
||||
KEY_ID_REGION_DELIVERY = 'id_region_delivery'
|
||||
KEY_BASKET: str = Basket.KEY_BASKET
|
||||
KEY_IS_INCLUDED_VAT = Basket.KEY_IS_INCLUDED_VAT # 'is_included_VAT'
|
||||
KEY_ID_CURRENCY = Basket.KEY_ID_CURRENCY # 'id_currency'
|
||||
KEY_ID_REGION_DELIVERY = Basket.KEY_ID_REGION_DELIVERY # 'id_region_delivery'
|
||||
# Attributes
|
||||
db: SQLAlchemy
|
||||
# Global constants
|
||||
@@ -112,7 +113,7 @@ class DataStore_Store():
|
||||
return category_list, errors # categories, category_index
|
||||
|
||||
|
||||
def edit_basket(self, ids_permutation_basket, quantities_permutation_basket, id_permutation_edit, quantity_permutation_edit, sum_not_edit, id_currency, id_region_delivery):
|
||||
def edit_basket(self, ids_permutation_basket, quantities_permutation_basket, id_permutation_edit, quantity_permutation_edit, sum_not_edit, id_currency, id_region_delivery, is_included_VAT):
|
||||
# redundant argument validation?
|
||||
_m = 'DataStore_Store.edit_basket'
|
||||
print(f'{_m}\nstarting...')
|
||||
@@ -176,7 +177,7 @@ class DataStore_Store():
|
||||
print(f'raw basket: {result_set}')
|
||||
# print(f'variations: {result_set_3}')
|
||||
# variations = [Variation(**row) for row in result_set_3]
|
||||
basket = Basket()
|
||||
basket = Basket(is_included_VAT, id_currency, id_region_delivery)
|
||||
for row in result_set:
|
||||
index_category = category_list.get_index_category_from_id(row[0])
|
||||
category = category_list.categories[index_category]
|
||||
@@ -732,7 +733,11 @@ class DataStore_Store():
|
||||
return regions, currencies
|
||||
|
||||
def get_metadata_basket(json_request):
|
||||
is_included_VAT = json_request[DataStore_Store.KEY_IS_INCLUDED_VAT]
|
||||
id_currency = json_request[DataStore_Store.KEY_ID_CURRENCY]
|
||||
id_region_delivery = json_request[DataStore_Store.KEY_ID_REGION_DELIVERY]
|
||||
try:
|
||||
basket = json_request[DataStore_Store.KEY_BASKET]
|
||||
except KeyError:
|
||||
basket = {DataStore_Store.KEY_IS_INCLUDED_VAT: True, DataStore_Store.KEY_ID_CURRENCY: 1, DataStore_Store.KEY_ID_REGION_DELIVERY: 1}
|
||||
is_included_VAT = basket[DataStore_Store.KEY_IS_INCLUDED_VAT]
|
||||
id_currency = basket[DataStore_Store.KEY_ID_CURRENCY]
|
||||
id_region_delivery = basket[DataStore_Store.KEY_ID_REGION_DELIVERY]
|
||||
return id_currency, id_region_delivery, is_included_VAT
|
||||
6
forms.py
6
forms.py
@@ -96,7 +96,9 @@ class Form_Is_Included_VAT(FlaskForm):
|
||||
is_included = BooleanField('Include VAT')
|
||||
|
||||
class Form_Delivery_Region(FlaskForm):
|
||||
id_region_delivery = SelectField('Region')
|
||||
id_id_region_delivery = 'id_region_delivery'
|
||||
id_region_delivery = SelectField('Region', id='id_region_delivery')
|
||||
|
||||
class Form_Currency(FlaskForm):
|
||||
id_currency = SelectField('Currency')
|
||||
id_id_currency = 'id_currency'
|
||||
id_currency = SelectField('Currency', id='id_currency')
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -38,15 +38,19 @@ class Model_View_Base(ABC):
|
||||
# app: Flask
|
||||
is_page_store: bool
|
||||
# Global constants
|
||||
ATTR_TEXT_COLLAPSED = 'textCollapsed'
|
||||
ATTR_TEXT_EXPANDED = 'textExpanded'
|
||||
FLAG_BUTTON_MODAL_CLOSE = 'btn-overlay-close'
|
||||
FLAG_BUTTON_SUBMIT = 'btn-submit'
|
||||
FLAG_CARD = 'card'
|
||||
FLAG_COLLAPSED = 'collapsed'
|
||||
FLAG_COLLAPSIBLE = 'collapsible'
|
||||
FLAG_COLUMN = 'column'
|
||||
FLAG_CONTAINER = 'container'
|
||||
FLAG_CONTAINER_INPUT = FLAG_CONTAINER + '-input'
|
||||
FLAG_EXPANDED = 'expanded'
|
||||
FLAG_INITIALISED = 'initialised'
|
||||
FLAG_ROW = 'column'
|
||||
FLAG_ROW = 'row'
|
||||
FLAG_SCROLLABLE = 'scrollable'
|
||||
FLAG_SUBMITTED = 'submitted'
|
||||
# flagIsDatePicker = 'is-date-picker'
|
||||
|
||||
@@ -67,26 +67,30 @@ class Model_View_Store(Model_View_Base):
|
||||
ID_BUTTON_CHECKOUT = 'btnCheckout'
|
||||
ID_BUTTON_BASKET_ADD = 'btnBasketAdd'
|
||||
ID_BUTTON_BUY_NOW = 'btnBuyNow'
|
||||
ID_CURRENCY = Form_Currency.id_id_currency # 'id_currency'
|
||||
ID_CURRENCY_DEFAULT = 1
|
||||
ID_LABEL_BASKET_EMPTY = 'basketEmpty'
|
||||
ID_REGION_DELIVERY = Form_Delivery_Region.id_id_region_delivery # 'id_region_delivery'
|
||||
ID_REGION_DELIVERY_DEFAULT = 1
|
||||
IS_INCLUDED_VAT_DEFAULT = True
|
||||
KEY_BASKET = 'basket'
|
||||
KEY_BASKET = Basket.KEY_BASKET # 'basket'
|
||||
# KEY_CODE_CURRENCY = 'code_currency'
|
||||
KEY_FORM = 'form'
|
||||
KEY_ID_CURRENCY = 'id_currency'
|
||||
KEY_ID_CURRENCY = Basket.KEY_ID_CURRENCY # 'id_currency'
|
||||
KEY_ID_PRODUCT = 'product_id'
|
||||
KEY_ID_PERMUTATION = 'permutation_id'
|
||||
KEY_ID_REGION_DELIVERY = 'id_region_delivery'
|
||||
KEY_IS_INCLUDED_VAT = 'is_included_VAT'
|
||||
KEY_ID_REGION_DELIVERY = Basket.KEY_ID_REGION_DELIVERY # 'id_region_delivery'
|
||||
KEY_IS_INCLUDED_VAT = Basket.KEY_IS_INCLUDED_VAT # 'is_included_VAT'
|
||||
KEY_ITEMS = Basket.KEY_ITEMS # 'items'
|
||||
KEY_PRICE = 'price'
|
||||
KEY_QUANTITY = 'quantity'
|
||||
KEY_VALUE_DEFAULT = 'default'
|
||||
TYPE_FORM_BASKET_ADD = 'Form_Basket_Add'
|
||||
TYPE_FORM_BASKET_EDIT = 'Form_Basket_Edit'
|
||||
# development variables
|
||||
# valid_product_id_list = ['prod_PB0NUOSEs06ymG']
|
||||
|
||||
def __new__(cls, db, info_user, app, id_currency, id_region_delivery): # , *args, **kwargs``
|
||||
def __new__(cls, db, info_user, app, id_currency, id_region_delivery, is_included_VAT): # , *args, **kwargs``
|
||||
# Initialiser - validation
|
||||
_m = 'Model_View_Store.__new__'
|
||||
v_arg_type = 'class attribute'
|
||||
@@ -95,26 +99,27 @@ class Model_View_Store(Model_View_Base):
|
||||
# return super().__new__(cls, *args, **kwargs)
|
||||
return super().__new__(cls, db, info_user, app) # Model_View_Store, cls
|
||||
|
||||
def __init__(self, db, info_user, app, id_currency, id_region_delivery):
|
||||
def __init__(self, db, info_user, app, id_currency, id_region_delivery, is_included_VAT):
|
||||
# Constructor
|
||||
_m = 'Model_View_Store.__init__'
|
||||
print(f'{_m}\nstarting')
|
||||
super().__init__(db, info_user, app)
|
||||
self.is_page_store = True
|
||||
self.basket = Basket()
|
||||
self.basket = Basket(id_currency, id_region_delivery, is_included_VAT)
|
||||
# self.basket_total = 0
|
||||
# self.db = db
|
||||
# if logged in:
|
||||
# else:
|
||||
self.id_currency = id_currency
|
||||
self.id_region_delivery = id_region_delivery
|
||||
self.is_included_VAT = is_included_VAT
|
||||
self.show_delivery_option = True
|
||||
self.form_is_included_VAT = Form_Is_Included_VAT()
|
||||
regions, currencies = self.get_regions_and_currencies()
|
||||
self.form_currency = Form_Currency()
|
||||
self.form_currency = Form_Currency(id_currency=self.id_currency)
|
||||
self.form_currency.id_currency.choices = [(currency.id_currency, f'{currency.code} - {currency.name}') for currency in currencies]
|
||||
self.form_currency.id_currency.data = str(self.id_currency) if len(currencies) > 0 else None
|
||||
self.form_delivery_region = Form_Delivery_Region()
|
||||
self.form_delivery_region = Form_Delivery_Region(id_region_delivery=self.id_region_delivery)
|
||||
self.form_delivery_region.id_region_delivery.choices = [(region.id_region, f'{region.code} - {region.name}') for region in regions]
|
||||
self.form_delivery_region.id_region_delivery.data = str(self.id_region_delivery) if len(regions) > 0 else None
|
||||
|
||||
@@ -203,14 +208,14 @@ class Model_View_Store(Model_View_Base):
|
||||
# item_added = False
|
||||
print(f'basket: {self.basket}')
|
||||
ids_permutation, quantities_permutation = self.basket.to_csv()
|
||||
self.basket = DataStore_Store(self.db, self.info_user, self.app).edit_basket(ids_permutation, quantities_permutation, permutation_id, quantity, quantity_sum_not_replace, self.app.id_currency, self.app.id_region_delivery)
|
||||
self.basket = DataStore_Store(self.db, self.info_user, self.app).edit_basket(ids_permutation, quantities_permutation, permutation_id, quantity, quantity_sum_not_replace, self.id_currency, self.id_region_delivery, self.is_included_VAT)
|
||||
return True
|
||||
|
||||
def get_basket(self, json_data):
|
||||
self.import_JSON_basket(json_data)
|
||||
if self.is_user_logged_in:
|
||||
ids_permutation, quantities_permutation = self.basket.to_csv()
|
||||
self.basket = DataStore_Store(self.db, self.info_user, self.app).edit_basket(ids_permutation, quantities_permutation, None, None, None, self.app.id_currency, self.app.id_region_delivery)
|
||||
self.basket = DataStore_Store(self.db, self.info_user, self.app).edit_basket(ids_permutation, quantities_permutation, None, None, None, self.id_currency, self.id_region_delivery, self.is_included_VAT)
|
||||
# return self.basket
|
||||
|
||||
def _get_json_basket_id_CSVs_product_permutation(self, basket):
|
||||
@@ -223,8 +228,8 @@ class Model_View_Store(Model_View_Base):
|
||||
product_ids += ','
|
||||
permutation_ids += ','
|
||||
basket_item = basket[index_item]
|
||||
id_product = basket_item[self.key_id_product]
|
||||
id_permutation = basket_item[self.key_id_permutation]
|
||||
id_product = basket_item[self.KEY_ID_PRODUCT]
|
||||
id_permutation = basket_item[self.KEY_ID_PERMUTATION]
|
||||
id_permutation = '' if (id_permutation is None or id_permutation == 'None') else str(id_permutation)
|
||||
product_ids += str(id_product) # str(basket[b].product.id)
|
||||
permutation_ids += id_permutation # str(basket[b].product.id)
|
||||
@@ -235,7 +240,7 @@ class Model_View_Store(Model_View_Base):
|
||||
return product_ids, permutation_ids, item_index_dict
|
||||
|
||||
def _get_basket_from_json(self, json_data):
|
||||
basket = json_data[self.key_basket]['items']
|
||||
basket = json_data[self.KEY_BASKET]['items']
|
||||
av.val_instance(basket, 'basket', 'Model_View_Store._get_basket_from_json', list)
|
||||
print(f'basket = {basket}')
|
||||
return basket
|
||||
@@ -244,6 +249,10 @@ class Model_View_Store(Model_View_Base):
|
||||
_m = 'Model_View_Store.import_JSON_basket'
|
||||
# av.val_instance(db, 'db', _m, SQLAlchemy)
|
||||
items = self._get_basket_from_json(json_data)
|
||||
basket = json_data[self.KEY_BASKET]
|
||||
id_currency = basket[self.KEY_ID_CURRENCY]
|
||||
id_region_delivery = basket[self.KEY_ID_REGION_DELIVERY]
|
||||
is_included_VAT = basket[self.KEY_IS_INCLUDED_VAT]
|
||||
print(f'json basket items: {items}')
|
||||
product_ids, permutation_ids, item_index_dict = self._get_json_basket_id_CSVs_product_permutation(items)
|
||||
category_list, errors = DataStore_Store(self.db, self.info_user, self.app).get_many_product_category(Product_Filters(
|
||||
@@ -252,12 +261,12 @@ class Model_View_Store(Model_View_Base):
|
||||
False, product_ids, False, False, # :a_get_all_product, :a_ids_product, :a_get_inactive_product, :a_get_first_product_only
|
||||
False, permutation_ids, False, # :a_get_all_permutation, :a_ids_permutation, :a_get_inactive_permutation
|
||||
False, '', False, True, # :a_get_all_image, :a_ids_image, :a_get_inactive_image, :a_get_first_image_only
|
||||
False, str(self.app.id_region_delivery), False, # :a_get_all_delivery_region, :a_ids_delivery_region, :a_get_inactive_delivery_region
|
||||
False, str(self.app.id_currency), False, # :a_get_all_currency, :a_ids_currency, :a_get_inactive_currency
|
||||
False, str(id_region_delivery), False, # :a_get_all_delivery_region, :a_ids_delivery_region, :a_get_inactive_delivery_region
|
||||
False, str(id_currency), False, # :a_get_all_currency, :a_ids_currency, :a_get_inactive_currency
|
||||
True, '', False # :a_get_all_discount, :a_ids_discount, :a_get_inactive_discount
|
||||
)) # product_ids=product_ids, get_all_category=False, get_all_product=False)
|
||||
# print(f'categories = {categories}')
|
||||
self.basket = Basket()
|
||||
self.basket = Basket(id_currency, id_region_delivery, is_included_VAT)
|
||||
if len(category_list.categories) > 0: # not (categories is None):
|
||||
for category in category_list.categories:
|
||||
for product in category.products:
|
||||
@@ -265,7 +274,7 @@ class Model_View_Store(Model_View_Base):
|
||||
product.form_basket_edit = Form_Basket_Edit()
|
||||
# key_index_product = Basket.get_key_product_index_from_ids_product_permutation(product.id_product, product.get_id_permutation())
|
||||
permutation = product.get_permutation_selected()
|
||||
self.basket.add_item(Basket_Item.make_from_product_and_quantity_and_VAT_included(product, items[item_index_dict[str(permutation.id_permutation)]][self.key_quantity], self.app.is_included_VAT))
|
||||
self.basket.add_item(Basket_Item.make_from_product_and_quantity_and_VAT_included(product, items[item_index_dict[str(permutation.id_permutation)]][self.KEY_QUANTITY], self.is_included_VAT))
|
||||
"""
|
||||
if len(items) > 0:
|
||||
for index_item in range(len(items)):
|
||||
@@ -317,8 +326,8 @@ class Model_View_Store(Model_View_Base):
|
||||
|
||||
# print(f'product id: {product_id}, type: {str(type(product_id))}')
|
||||
try:
|
||||
permutation_id = json_data[self.key_id_permutation]
|
||||
av.full_val_int(permutation_id, self.key_id_permutation, _m)
|
||||
permutation_id = json_data[self.KEY_ID_PERMUTATION]
|
||||
av.full_val_int(permutation_id, self.KEY_ID_PERMUTATION, _m)
|
||||
permutation_id = int(permutation_id)
|
||||
except:
|
||||
permutation_id = None
|
||||
|
||||
@@ -65,13 +65,13 @@ class Model_View_Store_Basket(Model_View_Store):
|
||||
def title(self):
|
||||
return 'Store Basket'
|
||||
|
||||
def __new__(cls, db, id_user, app, id_currency, id_region_delivery):
|
||||
def __new__(cls, db, id_user, app, id_currency, id_region_delivery, is_included_VAT):
|
||||
# Initialiser - validation
|
||||
return super(Model_View_Store_Basket, cls).__new__(cls, db, id_user, app, id_currency, id_region_delivery)
|
||||
return super(Model_View_Store_Basket, cls).__new__(cls, db, id_user, app, id_currency, id_region_delivery, is_included_VAT)
|
||||
|
||||
def __init__(self, db, id_user, app, id_currency, id_region_delivery):
|
||||
def __init__(self, db, id_user, app, id_currency, id_region_delivery, is_included_VAT):
|
||||
# Constructor
|
||||
super().__init__(db, id_user, app, id_currency, id_region_delivery)
|
||||
super().__init__(db, id_user, app, id_currency, id_region_delivery, is_included_VAT)
|
||||
# self.product_categories = Model_View_Store_Basket.get_many_product_category(get_all_category = True, get_all_product = True)
|
||||
self.form_billing = Form_Billing()
|
||||
self.form_billing.form_type_billing_not_delivery = True
|
||||
|
||||
@@ -41,13 +41,13 @@ class Model_View_Store_Checkout(Model_View_Store_Basket):
|
||||
def title(self):
|
||||
return 'Store Checkout'
|
||||
|
||||
def __new__(cls, db, id_user, app):
|
||||
def __new__(cls, db, id_user, app, id_currency, id_region_delivery, is_included_VAT):
|
||||
# Initialiser - validation
|
||||
return super(Model_View_Store_Checkout, cls).__new__(cls, db, id_user, app)
|
||||
return super(Model_View_Store_Checkout, cls).__new__(cls, db, id_user, app, id_currency, id_region_delivery, is_included_VAT)
|
||||
|
||||
def __init__(self, db, id_user, app):
|
||||
def __init__(self, db, id_user, app, id_currency, id_region_delivery, is_included_VAT):
|
||||
# Constructor
|
||||
super().__init__(db, id_user, app)
|
||||
super().__init__(db, id_user, app, id_currency, id_region_delivery, is_included_VAT)
|
||||
self.key_secret_stripe = os.environ.get("KEY_SECRET_STRIPE")
|
||||
self.key_public_stripe = os.environ.get("KEY_PUBLIC_STRIPE")
|
||||
|
||||
|
||||
@@ -40,16 +40,16 @@ class Model_View_Store_Checkout_Success(Model_View_Store_Checkout):
|
||||
def title(self):
|
||||
return 'Store Checkout Success'
|
||||
|
||||
def __new__(cls, db, id_user, app, id_checkout_session, checkout_items = None):
|
||||
def __new__(cls, db, id_user, app, id_checkout_session, checkout_items, id_currency, id_region_delivery, is_included_VAT):
|
||||
# Initialiser - validation
|
||||
_m = 'Model_View_Store_Checkout_Success.__new__'
|
||||
# av.val_list(checkout_items, 'checkout_items', _m)
|
||||
av.val_str(id_checkout_session, 'id_checkout_session', _m)
|
||||
return super(Model_View_Store_Checkout_Success, cls).__new__(cls, db, id_user, app)
|
||||
return super(Model_View_Store_Checkout_Success, cls).__new__(cls, db, id_user, app, id_currency, id_region_delivery, is_included_VAT)
|
||||
|
||||
def __init__(self, db, id_user, app, id_checkout_session, checkout_items = None):
|
||||
def __init__(self, db, id_user, app, id_checkout_session, checkout_items, id_currency, id_region_delivery, is_included_VAT):
|
||||
# Constructor
|
||||
super().__init__(db, id_user, app)
|
||||
super().__init__(db, id_user, app, id_currency, id_region_delivery, is_included_VAT)
|
||||
self.checkout_items = checkout_items
|
||||
self.id_checkout_session = id_checkout_session
|
||||
self.order = self.get_many_user_order('', 1, id_checkout_session)
|
||||
@@ -40,13 +40,13 @@ class Model_View_Store_Home(Model_View_Store):
|
||||
return 'Store Home'
|
||||
max_products_per_category = -1
|
||||
|
||||
def __new__(cls, db, id_user, app, id_currency, id_region_delivery):
|
||||
def __new__(cls, db, id_user, app, id_currency, id_region_delivery, is_included_VAT):
|
||||
# Initialiser - validation
|
||||
return super(Model_View_Store_Home, cls).__new__(cls, db, id_user, app, id_currency, id_region_delivery)
|
||||
return super(Model_View_Store_Home, cls).__new__(cls, db, id_user, app, id_currency, id_region_delivery, is_included_VAT)
|
||||
|
||||
def __init__(self, db, id_user, app, id_currency, id_region_delivery):
|
||||
def __init__(self, db, id_user, app, id_currency, id_region_delivery, is_included_VAT):
|
||||
# Constructor
|
||||
super().__init__(db, id_user, app, id_currency, id_region_delivery)
|
||||
super().__init__(db, id_user, app, id_currency, id_region_delivery, is_included_VAT)
|
||||
# self.categories = Model_View_Store_Home.get_many_product_category(self.db, get_all_category = True, get_all_product = True)
|
||||
# self.get_many_product_category(get_all_category = True, get_all_product = True)
|
||||
"""
|
||||
|
||||
@@ -37,7 +37,7 @@ class Model_View_Store_Product(Model_View_Store):
|
||||
def title(self):
|
||||
return 'Store Home'
|
||||
|
||||
def __new__(cls, db, id_user, app, id_permutation, id_currency, id_region_delivery): # *args, **kwargs
|
||||
def __new__(cls, db, id_user, app, id_permutation, id_currency, id_region_delivery, is_included_VAT): # *args, **kwargs
|
||||
# Initialiser - validation
|
||||
_m = 'Model_View_Store_Product.__new__'
|
||||
print(f'{_m}\nstarting...')
|
||||
@@ -51,13 +51,13 @@ class Model_View_Store_Product(Model_View_Store):
|
||||
print(f'ending')
|
||||
|
||||
# return super().__new__(cls, *args, **kwargs) # Model_View_Store_Product, cls # , db, id_user, id_product) # , db, id_user)
|
||||
return super(Model_View_Store_Product, cls).__new__(cls, db, id_user, app, id_currency, id_region_delivery)
|
||||
return super(Model_View_Store_Product, cls).__new__(cls, db, id_user, app, id_currency, id_region_delivery, is_included_VAT)
|
||||
|
||||
def __init__(self, db, id_user, app, id_permutation, id_currency, id_region_delivery):
|
||||
def __init__(self, db, id_user, app, id_permutation, id_currency, id_region_delivery, is_included_VAT):
|
||||
# Constructor
|
||||
_m = 'Model_View_Store_Product.__init__'
|
||||
print(f'{_m}\nstarting...')
|
||||
super().__init__(db, id_user, app, id_currency, id_region_delivery)
|
||||
super().__init__(db, id_user, app, id_currency, id_region_delivery, is_included_VAT)
|
||||
print('supered')
|
||||
print(f'user info: {self.info_user}')
|
||||
# print(f'user id: {self.info_user.get("sub")}')
|
||||
|
||||
@@ -57,6 +57,8 @@ h5 {
|
||||
border-bottom-left-radius: 2.5vh;
|
||||
border-bottom-right-radius: 2.5vh;
|
||||
flex-wrap: wrap;
|
||||
font-weight: bold;
|
||||
font-size: 2vh;
|
||||
}
|
||||
|
||||
/* Style the topnav links */
|
||||
@@ -82,6 +84,23 @@ h5 {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.topnav select {
|
||||
padding: 1vh;
|
||||
margin: 1vh;
|
||||
border-radius: 1vh;
|
||||
/* background-color: var(--c_purple_light); */
|
||||
color: var(--c_purple_dark);
|
||||
border: 2px solid white;
|
||||
font-weight: bold;
|
||||
text-align: center;
|
||||
}
|
||||
.topnav select .collapsed {
|
||||
width: 5vw;
|
||||
}
|
||||
.topnav select .expanded {
|
||||
width: 25vw;
|
||||
}
|
||||
|
||||
/* Create two unequal columns that floats next to each other */
|
||||
/* Left column */
|
||||
.leftcolumn {
|
||||
|
||||
@@ -81,6 +81,7 @@ function hookupOverlay(idOverlay) {
|
||||
}
|
||||
|
||||
function hookupSelectorCurrency() {
|
||||
/*
|
||||
let elForm = $(idFormCurrency);
|
||||
let elSelector = $(elForm.find('select')[0]);
|
||||
initialiseEventHandler(elSelector, flagInitialised, function(){
|
||||
@@ -97,8 +98,43 @@ function hookupSelectorCurrency() {
|
||||
});
|
||||
});
|
||||
console.log("form currency initialised")
|
||||
*/
|
||||
|
||||
let dropdownCurrency = $(idCurrency)[0];
|
||||
// dropdownCurrency.options.map(function(option) {
|
||||
let option, indexHyphen, textOption;
|
||||
for (let indexOption = 0; indexOption < dropdownCurrency.options.length; indexOption++) {
|
||||
option = $(dropdownCurrency.options[indexOption]);
|
||||
textOption = option.text();
|
||||
indexHyphen = textOption.indexOf('-');
|
||||
option.attr(attrTextExpanded, textOption);
|
||||
option.attr(attrTextCollapsed, textOption.substring(0, indexHyphen - 1));
|
||||
option.addClass(flagCollapsed);
|
||||
}
|
||||
handleSelectCollapse(dropdownCurrency);
|
||||
initialiseEventHandler(dropdownCurrency, flagInitialised, function() {
|
||||
dropdownCurrency = $(dropdownCurrency);
|
||||
dropdownCurrency.on("focus", function() {
|
||||
handleSelectExpand(dropdownCurrency);
|
||||
});
|
||||
dropdownCurrency.on("blur", function() {
|
||||
handleSelectCollapse(dropdownCurrency);
|
||||
});
|
||||
dropdownCurrency.on("change", function() {
|
||||
let selectedCurrency = dropdownCurrency.val();
|
||||
console.log("selected currency: ", selectedCurrency);
|
||||
let basket = getLocalStorage(keyBasket);
|
||||
basket[keyIdCurrency] = selectedCurrency;
|
||||
// setLocalStorage(keyIdCurrency, selectedCurrency);
|
||||
setLocalStorage(keyBasket, basket);
|
||||
let ajaxData = {};
|
||||
ajaxData[keyBasket] = basket;
|
||||
ajaxJSONData('update currency', mapHashToController(hashPageCurrent), ajaxData, loadPageBody, false);
|
||||
});
|
||||
});
|
||||
}
|
||||
function hookupSelectorDeliveryRegion() {
|
||||
/*
|
||||
let elForm = $(idFormDeliveryRegion);
|
||||
let elSelector = $(elForm.find('select')[0]);
|
||||
initialiseEventHandler(elSelector, flagInitialised, function(){
|
||||
@@ -111,7 +147,62 @@ function hookupSelectorDeliveryRegion() {
|
||||
});
|
||||
console.log("form delivery region initialised")
|
||||
});
|
||||
*/
|
||||
|
||||
let dropdownRegion = $(idRegionDelivery)[0];
|
||||
|
||||
let option, indexHyphen, textOption;
|
||||
for (let indexOption = 0; indexOption < dropdownRegion.options.length; indexOption++) {
|
||||
option = $(dropdownRegion.options[indexOption]);
|
||||
textOption = option.text();
|
||||
indexHyphen = textOption.indexOf('-');
|
||||
option.attr(attrTextExpanded, textOption);
|
||||
option.attr(attrTextCollapsed, textOption.substring(0, indexHyphen - 1));
|
||||
option.addClass(flagCollapsed);
|
||||
}
|
||||
|
||||
handleSelectCollapse(dropdownRegion);
|
||||
|
||||
initialiseEventHandler(dropdownRegion, flagInitialised, function() {
|
||||
dropdownRegion = $(dropdownRegion);
|
||||
dropdownRegion.on("focus", function() {
|
||||
console.log("dropdown region focused");
|
||||
handleSelectExpand(dropdownRegion);
|
||||
});
|
||||
dropdownRegion.on("blur", function() {
|
||||
console.log("dropdown region blurred");
|
||||
handleSelectCollapse(dropdownRegion);
|
||||
});
|
||||
dropdownRegion.on("change", function() {
|
||||
handleSelectCollapse(dropdownRegion);
|
||||
let selectedRegion = dropdownRegion.val();
|
||||
console.log("selected region: ", selectedRegion);
|
||||
let basket = getLocalStorage(keyBasket);
|
||||
basket[keyIdRegionDelivery] = selectedRegion;
|
||||
// setLocalStorage(keyIdRegionDelivery, selectedRegion);
|
||||
setLocalStorage(keyBasket, basket);
|
||||
let ajaxData = {};
|
||||
ajaxData[keyIdRegionDelivery] = selectedRegion;
|
||||
ajaxJSONData('update region', mapHashToController(hashStoreSetRegion), ajaxData, null, false);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function handleSelectCollapse(elementSelect) {
|
||||
let optionSelected = $(elementSelect).find('option:selected');
|
||||
optionSelected.text(optionSelected.attr(attrTextCollapsed));
|
||||
console.log('collapsed: ', optionSelected.text());
|
||||
optionSelected.removeClass(flagExpanded);
|
||||
optionSelected.addClass(flagCollapsed);
|
||||
}
|
||||
function handleSelectExpand(elementSelect) {
|
||||
let optionSelected = $(elementSelect).find('option:selected');
|
||||
optionSelected.text(optionSelected.attr(attrTextExpanded));
|
||||
console.log('expanded: ', optionSelected.text());
|
||||
optionSelected.removeClass(flagCollapsed);
|
||||
optionSelected.addClass(flagExpanded);
|
||||
}
|
||||
|
||||
function hookupCheckboxIsIncludedVAT() {
|
||||
let elForm = $(idFormIsIncludedVAT);
|
||||
let elSelector = $(elForm.find('input[type="checkbox"]')[0]);
|
||||
|
||||
@@ -11,7 +11,6 @@ function hookupStore() {
|
||||
function hookupBasket() {
|
||||
|
||||
// const containerBasket = $(idContainerBasket);
|
||||
|
||||
toggleShowBtnCheckout(); // containerBasket
|
||||
hookupBtnCheckout();
|
||||
hookupBtnsPlusMinus();
|
||||
@@ -45,13 +44,19 @@ function hookupLocalStorageStore() {
|
||||
|
||||
}
|
||||
if (createNewBasket) {
|
||||
basket = {'items': []};
|
||||
basket = {};
|
||||
basket[keyItems] = [];
|
||||
basket[keyIsIncludedVAT] = true;
|
||||
basket[keyIdCurrency] = 1;
|
||||
basket[keyIdRegionDelivery] = 1;
|
||||
setLocalStorage(keyBasket, basket);
|
||||
console.log("new local basket created");
|
||||
}
|
||||
let ajaxData = {}
|
||||
ajaxData[keyBasket] = basket;
|
||||
// console.log('ajax:' + ajaxData);
|
||||
// console.log("hookupLocalStorageStore\nhashStoreBasketLoad: " + hashStoreBasketLoad + "\n");
|
||||
// ajaxData[keyIsIncludedVAT] = getLocalStorage(keyIsIncludedVAT);
|
||||
console.log('ajax:' + ajaxData);
|
||||
ajaxJSONData(keyBasket, mapHashToController(hashStoreBasketLoad), ajaxData, loadBasket, false);
|
||||
}
|
||||
|
||||
|
||||
@@ -178,6 +178,14 @@ BEGIN
|
||||
SET a_get_inactive_discount = 0;
|
||||
END IF;
|
||||
|
||||
/*
|
||||
SELECT a_id_user, a_get_all_category, a_ids_category, a_get_inactive_category, a_get_all_product,
|
||||
a_ids_product, a_get_inactive_product, a_get_first_product_only, a_get_all_product_permutation, a_ids_permutation,
|
||||
a_get_inactive_permutation, a_get_all_image, a_ids_image, a_get_inactive_image, a_get_first_image_only,
|
||||
a_get_all_delivery_region, a_ids_delivery_region, a_get_inactive_delivery_region, a_get_all_currency, a_ids_currency,
|
||||
a_get_inactive_currency, a_get_all_discount, a_ids_discount, a_get_inactive_discount
|
||||
;
|
||||
*/
|
||||
|
||||
-- Temporary tables
|
||||
DROP TABLE IF EXISTS tmp_Discount;
|
||||
@@ -277,7 +285,8 @@ BEGIN
|
||||
FOREIGN KEY (id_region)
|
||||
REFERENCES Shop_Region(id_region),
|
||||
active BIT NOT NULL,
|
||||
display_order INT NOT NULL
|
||||
display_order INT NOT NULL,
|
||||
requires_delivery_option BIT NOT NULL DEFAULT 0
|
||||
);
|
||||
|
||||
CREATE TABLE tmp_Currency (
|
||||
@@ -506,18 +515,20 @@ BEGIN
|
||||
INSERT INTO tmp_Delivery_Region (
|
||||
id_region,
|
||||
active,
|
||||
display_order
|
||||
display_order,
|
||||
requires_delivery_option
|
||||
)
|
||||
WITH RECURSIVE Recursive_CTE_Delivery_Region AS (
|
||||
SELECT
|
||||
DR.id_region AS id_region_parent,
|
||||
NULL AS id_region_child
|
||||
FROM Shop_Region DR
|
||||
INNER JOIN Shop_Product_Delivery_Option_Link PDOL
|
||||
ON DR.id_region = PDOL.id_region
|
||||
INNER JOIN tmp_Shop_Product t_P
|
||||
ON PDOL.id_product = t_P.id_product
|
||||
AND PDOL.id_permutation <=> t_P.id_permutation
|
||||
NULL AS id_region_child,
|
||||
CASE WHEN FIND_IN_SET(DR.id_region, a_ids_delivery_region) > 0 THEN 1 ELSE 0 END AS requires_delivery_option
|
||||
FROM Shop_Product_Currency_Region_Link PCRL
|
||||
INNER JOIN Shop_Currency C ON PCRL.id_currency = C.id_currency
|
||||
INNER JOIN tmp_Shop_Product t_P
|
||||
ON PCRL.id_product <=> t_P.id_product
|
||||
AND PCRL.id_permutation <=> t_P.id_permutation
|
||||
INNER JOIN Shop_Region DR ON PCRL.id_region_purchase = DR.id_region
|
||||
WHERE
|
||||
(
|
||||
a_get_all_delivery_region
|
||||
@@ -525,39 +536,79 @@ BEGIN
|
||||
)
|
||||
AND (
|
||||
a_get_inactive_delivery_region
|
||||
OR DR.active
|
||||
OR DR.active = 1
|
||||
)
|
||||
UNION
|
||||
SELECT
|
||||
DRB.id_region_parent,
|
||||
DRB.id_region_child
|
||||
DRB.id_region_child,
|
||||
0 AS requires_delivery_option
|
||||
FROM Shop_Region_Branch DRB
|
||||
INNER JOIN Recursive_CTE_Delivery_Region r_DR
|
||||
ON DRB.id_region_parent = r_DR.id_region_child
|
||||
AND (
|
||||
a_get_inactive_delivery_region
|
||||
OR DRB.active
|
||||
OR DRB.active = 1
|
||||
)
|
||||
)
|
||||
SELECT
|
||||
DR.id_region,
|
||||
DR.active,
|
||||
DR.display_order
|
||||
DR.display_order,
|
||||
requires_delivery_option
|
||||
FROM Shop_Region DR
|
||||
INNER JOIN Recursive_CTE_Delivery_Region r_DR
|
||||
ON DR.id_region = r_DR.id_region_parent
|
||||
OR DR.id_region = r_DR.id_region_child
|
||||
;
|
||||
/*
|
||||
select * from tmp_delivery_region;
|
||||
SELECT *
|
||||
FROM tmp_Shop_Product t_P
|
||||
WHERE
|
||||
/*(
|
||||
a_get_all_category
|
||||
OR a_get_all_product
|
||||
OR a_get_all_product_permutation
|
||||
)*
|
||||
FIND_IN_SET(t_P.id_category, a_ids_category) > 0
|
||||
OR FIND_IN_SET(t_P.id_product, a_ids_product) > 0
|
||||
OR FIND_IN_SET(t_P.id_permutation, a_ids_permutation) > 0
|
||||
;
|
||||
*/
|
||||
|
||||
IF v_has_filter_delivery_region THEN
|
||||
SET v_ids_permutation_unavailable = (
|
||||
SELECT GROUP_CONCAT(t_P.id_permutation SEPARATOR ', ')
|
||||
FROM tmp_Shop_Product t_P
|
||||
INNER JOIN Shop_Product_Currency_Region_Link PCRL
|
||||
ON t_P.id_permutation = PCRL.id_permutation
|
||||
FROM (
|
||||
SELECT *
|
||||
FROM tmp_Shop_Product t_P
|
||||
WHERE
|
||||
/*(
|
||||
a_get_all_category
|
||||
OR a_get_all_produc
|
||||
OR a_get_all_product_permutation
|
||||
)*/
|
||||
FIND_IN_SET(t_P.id_category, a_ids_category) > 0
|
||||
OR FIND_IN_SET(t_P.id_product, a_ids_product) > 0
|
||||
OR FIND_IN_SET(t_P.id_permutation, a_ids_permutation) > 0
|
||||
) t_P
|
||||
LEFT JOIN (
|
||||
SELECT *
|
||||
FROM Shop_Product_Currency_Region_Link PCRL
|
||||
WHERE
|
||||
(
|
||||
a_get_all_delivery_region
|
||||
OR FIND_IN_SET(PCRL.id_region_purchase, a_ids_delivery_region) > 0
|
||||
)
|
||||
) PCRL
|
||||
ON t_P.id_product <=> PCRL.id_product
|
||||
AND t_P.id_permutation <=> PCRL.id_permutation
|
||||
LEFT JOIN tmp_Delivery_Region t_DR
|
||||
ON PCRL.id_region_purchase = t_DR.id_region
|
||||
WHERE ISNULL(t_DR.id_region)
|
||||
AND t_DR.requires_delivery_option = 1
|
||||
WHERE
|
||||
ISNULL(t_DR.id_region)
|
||||
);
|
||||
IF NOT ISNULL(v_ids_permutation_unavailable) THEN
|
||||
INSERT INTO tmp_Msg_Error (
|
||||
@@ -586,7 +637,7 @@ BEGIN
|
||||
-- select * from tmp_Shop_Product;
|
||||
|
||||
# Currencies
|
||||
IF NOT EXISTS (SELECT * FROM tmp_Msg_Error) THEN
|
||||
IF NOT EXISTS (SELECT * FROM tmp_Msg_Error WHERE guid = v_guid) THEN
|
||||
INSERT INTO tmp_Currency (
|
||||
id_currency,
|
||||
active,
|
||||
@@ -625,14 +676,14 @@ BEGIN
|
||||
SELECT *
|
||||
FROM tmp_Shop_Product t_P
|
||||
WHERE
|
||||
(
|
||||
/*(
|
||||
a_get_all_category
|
||||
OR a_get_all_product
|
||||
OR a_get_all_product_permutation
|
||||
)
|
||||
AND FIND_IN_SET(t_P.id_category, a_ids_category) = 0
|
||||
AND FIND_IN_SET(t_P.id_product, a_ids_product) = 0
|
||||
AND FIND_IN_SET(t_P.id_permutation, a_ids_permutation) = 0
|
||||
)*/
|
||||
FIND_IN_SET(t_P.id_category, a_ids_category) > 0
|
||||
OR FIND_IN_SET(t_P.id_product, a_ids_product) > 0
|
||||
OR FIND_IN_SET(t_P.id_permutation, a_ids_permutation) > 0
|
||||
) t_P
|
||||
INNER JOIN (
|
||||
SELECT *
|
||||
@@ -674,30 +725,31 @@ BEGIN
|
||||
END IF;
|
||||
|
||||
# Discounts
|
||||
INSERT INTO tmp_Discount (
|
||||
id_discount,
|
||||
active,
|
||||
display_order
|
||||
)
|
||||
SELECT
|
||||
D.id_discount,
|
||||
D.active,
|
||||
D.display_order
|
||||
FROM Shop_Discount D
|
||||
INNER JOIN tmp_Shop_Product t_P
|
||||
ON D.id_product = t_P.id_product
|
||||
AND D.id_permutation <=> t_P.id_permutation
|
||||
WHERE
|
||||
(
|
||||
a_get_all_discount
|
||||
OR FIND_IN_SET(D.id_discount, a_ids_discount) > 0
|
||||
IF NOT EXISTS (SELECT * FROM tmp_Msg_Error WHERE guid = v_guid) THEN
|
||||
INSERT INTO tmp_Discount (
|
||||
id_discount,
|
||||
active,
|
||||
display_order
|
||||
)
|
||||
AND (
|
||||
a_get_inactive_discount
|
||||
OR D.active
|
||||
)
|
||||
;
|
||||
|
||||
SELECT
|
||||
D.id_discount,
|
||||
D.active,
|
||||
D.display_order
|
||||
FROM Shop_Discount D
|
||||
INNER JOIN tmp_Shop_Product t_P
|
||||
ON D.id_product = t_P.id_product
|
||||
AND D.id_permutation <=> t_P.id_permutation
|
||||
WHERE
|
||||
(
|
||||
a_get_all_discount
|
||||
OR FIND_IN_SET(D.id_discount, a_ids_discount) > 0
|
||||
)
|
||||
AND (
|
||||
a_get_inactive_discount
|
||||
OR D.active
|
||||
)
|
||||
;
|
||||
END IF;
|
||||
# select 'pre-permission results';
|
||||
# select * from tmp_Shop_Product;
|
||||
|
||||
@@ -725,7 +777,7 @@ BEGIN
|
||||
|
||||
DELETE FROM tmp_Shop_Product t_P
|
||||
WHERE
|
||||
FIND_IN_SET(t_P.id_product, (SELECT GROUP_CONCAT(UET.id_product SEPARATOR ',') FROM Shop_User_Eval_Temp UET)) = 0 # id_product NOT LIKE CONCAT('%', (SELECT GROUP_CONCAT(id_product SEPARATOR '|') FROM Shop_User_Eval_Temp), '%');
|
||||
FIND_IN_SET(t_P.id_permutation, (SELECT GROUP_CONCAT(UET.id_permutation SEPARATOR ',') FROM Shop_User_Eval_Temp UET)) = 0 # id_product NOT LIKE CONCAT('%', (SELECT GROUP_CONCAT(id_product SEPARATOR '|') FROM Shop_User_Eval_Temp), '%');
|
||||
OR (
|
||||
ISNULL(t_P.can_view)
|
||||
AND (
|
||||
@@ -833,6 +885,13 @@ BEGIN
|
||||
ON t_P.id_permutation = PPVL.id_permutation
|
||||
ORDER BY t_P.display_order
|
||||
;
|
||||
*/
|
||||
-- select * from Shop_Product_Currency_Region_Link;
|
||||
-- select * from shop_currency;
|
||||
/*
|
||||
select * from tmp_Currency;
|
||||
select * from tmp_delivery_region;
|
||||
select * from tmp_shop_product;
|
||||
*/
|
||||
|
||||
# Product Price
|
||||
@@ -851,8 +910,8 @@ BEGIN
|
||||
ROW_NUMBER() OVER(ORDER BY t_P.rank_permutation, C.display_order) AS display_order
|
||||
FROM Shop_Product_Currency_Region_Link PCRL
|
||||
INNER JOIN tmp_Shop_Product t_P
|
||||
ON t_P.id_product = PCRL.id_product
|
||||
AND t_P.id_permutation <=> PCRL.id_permutation
|
||||
ON PCRL.id_product <=> t_P.id_product
|
||||
AND PCRL.id_permutation <=> t_P.id_permutation
|
||||
-- INNER JOIN Shop_Product P ON PCRL.id_product = P.id_product
|
||||
INNER JOIN tmp_Currency t_C ON PCRL.id_currency = t_C.id_currency
|
||||
INNER JOIN Shop_Currency C ON t_C.id_currency = C.id_currency
|
||||
@@ -1056,7 +1115,7 @@ CALL p_shop_get_many_product (
|
||||
0, # a_get_inactive_product
|
||||
0, # a_get_first_product_only
|
||||
1, # a_get_all_product_permutation
|
||||
'', # a_ids_permutation
|
||||
'1,2,3,4,5,6', # a_ids_permutation
|
||||
0, # a_get_inactive_permutation
|
||||
0, # a_get_all_image
|
||||
'', # a_ids_image
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<!-- Basket -->
|
||||
{% set show_delivery_option = False %}
|
||||
<div id="{{ model.id_basket }}" class="{{ model.flag_card }} {{ model.flag_scrollable }}">
|
||||
<div id="{{ model.ID_BASKET }}" class="{{ model.FLAG_CARD }} {{ model.FLAG_SCROLLABLE }}">
|
||||
<div class="container column">
|
||||
<div class="container row">
|
||||
<h2>Basket</h2>
|
||||
@@ -9,10 +9,10 @@
|
||||
{% for basket_item in model.basket.items %}
|
||||
{% include '_block_store_basket_item.html' %}
|
||||
{% endfor %}
|
||||
<h3 id="{{ model.id_basket_total }}">Total: {{ model.output_basket_total() }}</h3>{% if not model.app.is_included_VAT %}<h4> + VAT </h4>{% endif %}
|
||||
<p id="{{ model.id_label_basket_empty}}" style="margin: 1vh;">Buy some shit dawg!</p>
|
||||
<h3 id="{{ model.ID_BASKET_TOTAL }}">Total: {{ model.output_basket_total() }}</h3>{% if not model.app.is_included_VAT %}<h4> + VAT </h4>{% endif %}
|
||||
<p id="{{ model.ID_LABEL_BASKET_EMPTY }}" style="margin: 1vh;">Buy some shit dawg!</p>
|
||||
<!-- <div id="{{ model.id_basket_notices }}"> include line above
|
||||
</div> -->
|
||||
<button id="{{ model.id_btn_checkout }}" type="submit">Checkout</button>
|
||||
<button id="{{ model.ID_BUTTON_CHECKOUT }}" type="submit">Checkout</button>
|
||||
</div>
|
||||
</div>
|
||||
35
templates/_block_store_home_body.html
Normal file
35
templates/_block_store_home_body.html
Normal file
@@ -0,0 +1,35 @@
|
||||
|
||||
|
||||
{% set block_id = 'styles' %}
|
||||
{% include '_shared_store.html' %}
|
||||
<!-- Include Stylesheet -->
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='css/store_home.css') }}">
|
||||
|
||||
<!-- HTML content -->
|
||||
<div class="model.FLAG_ROW">
|
||||
<div class="leftcolumn">
|
||||
{% for cat in model.category_list.categories %}
|
||||
{% if cat.is_available() %}
|
||||
{% include '_block_store_product_category.html' %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
<div id="{{ model.ID_BASKET_CONTAINER}}" class="rightcolumn">
|
||||
{% include '_block_store_basket.html' %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% set block_id = 'scripts' %}
|
||||
{% include '_shared_store.html' %}
|
||||
<!-- Include JavaScript -->
|
||||
<script src="{{ url_for('static', filename='js/store_home.js') }}"></script>
|
||||
|
||||
<script>
|
||||
var hashPageCurrent = "{{ model.HASH_PAGE_STORE_HOME }}";
|
||||
|
||||
$(document).ready(function() {
|
||||
console.log('Hooking up home page...');
|
||||
hookupStorePageHome();
|
||||
// hookupStore(); // in _shared_store.html
|
||||
});
|
||||
</script>
|
||||
@@ -1,22 +1,24 @@
|
||||
<!-- Store Product Card
|
||||
for insertion in _store_product_category_card
|
||||
-->
|
||||
{% set permutation = product.get_permutation_selected() %}
|
||||
<div class="card subcard" {{ model.attr_id_product }}="{{ product.id_product }}" {{ model.attr_id_permutation }}="{{ permutation.id_permutation }}">
|
||||
<div class="container">
|
||||
<img class="img-product" src="{{ permutation.get_image_from_index(0).url }}" alt="Template product image"> <!-- model.get_many_product_image_src(product.id_product, '', True, 'FULL') -->
|
||||
</div>
|
||||
{% set form = product.form_basket_add %}
|
||||
<form {{ model.attr_form_type }}="{{ form.form_type }}" {{ model.attr_id_product }}="{{ product.id_product }}" {{ model.attr_id_permutation }}="{{ permutation.id_permutation }}" class="container column" action="{{ url_for('basket_add') }}" method="POST">
|
||||
{{ form.hidden_tag() }}
|
||||
<h2>{{ product.name }}</h2>
|
||||
<h3>{{ permutation.output_price(model.app.is_included_VAT) }}</h3>
|
||||
{% if permutation.is_available %}
|
||||
{% set tmp_quantity = 1 %}
|
||||
{% include '_block_input_number_plus_minus.html' %}
|
||||
{{ form.submit() }}
|
||||
<p>Get it: <strong>{{ permutation.output_delivery_date() }}</strong></p>
|
||||
{% if product.has_permutations() %}
|
||||
{% set permutation = product.get_permutation_selected() %}
|
||||
<div class="card subcard" {{ model.attr_id_product }}="{{ product.id_product }}" {{ model.attr_id_permutation }}="{{ permutation.id_permutation }}">
|
||||
<div class="container">
|
||||
<img class="img-product" src="{{ permutation.get_image_from_index(0).url }}" alt="Template product image"> <!-- model.get_many_product_image_src(product.id_product, '', True, 'FULL') -->
|
||||
</div>
|
||||
{% if permutation.is_available() %}
|
||||
{% set form = product.form_basket_add %}
|
||||
<form {{ model.attr_form_type }}="{{ form.form_type }}" {{ model.attr_id_product }}="{{ product.id_product }}" {{ model.attr_id_permutation }}="{{ permutation.id_permutation }}" class="container column" action="{{ url_for('basket_add') }}" method="POST">
|
||||
{{ form.hidden_tag() }}
|
||||
<h2>{{ product.name }}</h2>
|
||||
<h3>{{ permutation.output_price(model.is_included_VAT) }}</h3>
|
||||
{% set tmp_quantity = 1 %}
|
||||
{% include '_block_input_number_plus_minus.html' %}
|
||||
{{ form.submit() }}
|
||||
<p>Get it: <strong>{{ permutation.output_delivery_date() }}</strong></p>
|
||||
</form>
|
||||
{% endif %}
|
||||
</form>
|
||||
<!-- { % inc !!!! broken to ignore !!!! lude '_block_store_product_price!!!! broken to ignore !!!!.html' % } -->
|
||||
</div>
|
||||
<!-- { % inc !!!! broken to ignore !!!! lude '_block_store_product_price!!!! broken to ignore !!!!.html' % } -->
|
||||
</div>
|
||||
{% endif %}
|
||||
@@ -69,7 +69,7 @@
|
||||
<script src="{{ url_for('static', filename='js/store_shared.js') }}"></script>
|
||||
|
||||
<script>
|
||||
var hashPageCurrent = "{{ model.hash_page_home }}";
|
||||
var hashPageCurrent = "{{ model.HASH_PAGE_STORE_ADMIN_HOME }}";
|
||||
|
||||
$(document).ready(function() {
|
||||
hookupPageStoreAdminHome();
|
||||
|
||||
@@ -9,30 +9,30 @@
|
||||
<!-- <link rel="stylesheet" href="{{ url_for('static', filename='css/store_home.css') }}"> css/store_basket.css -->
|
||||
|
||||
<!-- HTML content -->
|
||||
<div class="{{ model.flag_card }}">
|
||||
<div class="{{ model.flag_container }} {{ model.flag_column }}">
|
||||
<div id="{{ model.id_container_info_delivery }}" class="{{ model.flag_container }} {{ model.flag_row }}" style="border-bottom: 1px black;">
|
||||
<div class="{{ model.FLAG_CARD }}">
|
||||
<div class="{{ model.FLAG_CONTAINER }} {{ model.FLAG_COLUMN }}">
|
||||
<div id="{{ model.ID_CONTAINER_INFO_DELIVERY }}" class="{{ model.FLAG_CONTAINER }} {{ model.FLAG_ROW }}" style="border-bottom: 1px black;">
|
||||
<h2>Delivery Information</h2>
|
||||
<div class="{{ model.flag_container }} {{ model.flag_row }}">
|
||||
<div class="{{ model.FLAG_CONTAINER }} {{ model.FLAG_ROW }}">
|
||||
Valid delivery information not submitted
|
||||
</div>
|
||||
</div>
|
||||
<div id="{{ model.id_container_info_billing }}" class="{{ model.flag_container }} {{ model.flag_row }}" style="border-bottom: 1px black;">
|
||||
<div id="{{ model.ID_CONTAINER_INFO_BILLING }}" class="{{ model.FLAG_CONTAINER }} {{ model.FLAG_ROW }}" style="border-bottom: 1px black;">
|
||||
<h2>Billing Information</h2>
|
||||
<div class="{{ model.flag_container }} {{ model.flag_row }}">
|
||||
<div class="{{ model.FLAG_CONTAINER }} {{ model.FLAG_ROW }}">
|
||||
Valid billing information not submitted
|
||||
</div>
|
||||
</div>
|
||||
<div class="{{ model.flag_container }}">
|
||||
<div id="{{ model.id_basket_container }}">
|
||||
<div class="{{ model.FLAG_CONTAINER }}">
|
||||
<div id="{{ model.ID_BASKET_CONTAINER }}">
|
||||
{% include '_block_store_basket.html' %}
|
||||
</div>
|
||||
<!-- Comes with basket block
|
||||
<div class="{{ model.flag_container }}">
|
||||
<div class="{{ model.FLAG_CONTAINER }}">
|
||||
<!-- subtotal --
|
||||
<h2 id="id_basket_total">Order total: £{{ model.output_basket_total() }}</h2>
|
||||
<h2 id="id_basket_total">Order total: £{{ model.OUTPUT_BASKET_TOTAL() }}</h2>
|
||||
<!-- checkout button - hidden unless valid details entered everywhere above --
|
||||
<button type="submit" class="{{ model.flag_btn_submit }}">Complete Purchase</button>
|
||||
<button type="submit" class="{{ model.FLAG_BTN_SUBMIT }}">Complete Purchase</button>
|
||||
</div>
|
||||
-->
|
||||
</div>
|
||||
@@ -54,31 +54,10 @@
|
||||
{% set block_id = 'scripts' %}
|
||||
{% include '_shared_store.html' %}
|
||||
<script src="{{ url_for('static', filename='js/store_page_basket.js') }}"></script>
|
||||
|
||||
{% set block_id = 'checkout' %}
|
||||
{% include '_shared_store.html' %}
|
||||
<script>
|
||||
var hashPageCurrent = "{{ model.hash_page_store_basket }}";
|
||||
var hashPageStoreCheckout = "{{ model.hash_page_store_checkout }}";
|
||||
var hashPageStoreCheckoutSession = "{{ model.hash_page_store_checkout_session }}";
|
||||
var hashStoreBasketInfo = "{{ model.hash_store_basket_info }}";
|
||||
var idOverlayInfoBilling = "#{{ model.id_overlay_info_billing }}";
|
||||
var idOverlayInfoDelivery = "#{{ model.id_overlay_info_delivery }}";
|
||||
var idContainerInfoBilling = "#{{ model.id_container_info_billing }}";
|
||||
var idContainerInfoDelivery = "#{{ model.id_container_info_delivery }}";
|
||||
var keyIdCheckout = "{{ model.key_id_checkout }}";
|
||||
var keyInfoBilling = "{{ model.key_info_billing }}";
|
||||
var keyInfoDelivery = "{{ model.key_info_delivery }}";
|
||||
var keyInfoIdentical = "{{ model.key_info_identical }}";
|
||||
var keyInfoType = "{{ model.key_info_type }}";
|
||||
var keyIsSubscription = "{{ model.key_is_subscription }}";
|
||||
var keyAddress1 = "{{ model.key_address1 }}";
|
||||
var keyAddress2 = "{{ model.key_address2 }}";
|
||||
var keyCity = "{{ model.key_city }}";
|
||||
var keyCounty = "{{ model.key_county }}";
|
||||
var keyNameFull = "{{ model.key_name_full }}";
|
||||
var keyPhoneNumber = "{{ model.key_phone_number }}";
|
||||
var keyPostcode = "{{ model.key_postcode }}";
|
||||
var keyRegion = "{{ model.key_region }}";
|
||||
var keyUrlCheckout = "{{ model.key_url_checkout }}";
|
||||
var hashPageCurrent = "{{ model.HASH_PAGE_STORE_BASKET }}";
|
||||
|
||||
$(document).ready(function() {
|
||||
console.log('Hooking up store basket review page...');
|
||||
|
||||
@@ -9,16 +9,16 @@
|
||||
<!-- <link rel="stylesheet" href="{{ url_for('static', filename='css/store_home.css') }}"> css/store_basket.css -->
|
||||
|
||||
<!-- HTML content -->
|
||||
<div class="{{ model.flag_card }}">
|
||||
<div class="{{ model.flag_container }} {{ model.flag_column }}">
|
||||
<div id="{{ model.id_container_info_delivery }}" class="{{ model.flag_container }} {{ model.flag_row }}" style="border-bottom: 1px black;">
|
||||
<div class="{{ model.FLAG_CARD }}">
|
||||
<div class="{{ model.FLAG_CONTAINER }} {{ model.FLAG_COLUMN }}">
|
||||
<div id="{{ model.ID_CONTAINER_INFO_DELIVERY }}" class="{{ model.FLAG_CONTAINER }} {{ model.FLAG_ROW }}" style="border-bottom: 1px black;">
|
||||
<h2>Order successful!</h2>
|
||||
<div class="{{ model.flag_container }} {{ model.flag_row }}">
|
||||
<div class="{{ model.flag_label }}"><strong>Order reference: {{ model.checkout_session.id }}</strong></div>
|
||||
<div class="{{ model.flag_label }}">You will receive an order acknowledgement by email</div>
|
||||
<div class="{{ model.FLAG_CONTAINER }} {{ model.FLAG_ROW }}">
|
||||
<div class="{{ model.FLAG_LABEL }}"><strong>Order reference: {{ model.CHECKOUT_SESSION.ID }}</strong></div>
|
||||
<div class="{{ model.FLAG_LABEL }}">You will receive an order acknowledgement by email</div>
|
||||
</div>
|
||||
{% if model.is_user_logged_in %}
|
||||
<div class="{{ model.flag_container }} {{ model.flag_row }}">
|
||||
{% if model.IS_USER_LOGGED_IN %}
|
||||
<div class="{{ model.FLAG_CONTAINER }} {{ model.FLAG_ROW }}">
|
||||
<h3>Your order:</h3>
|
||||
</div>
|
||||
{% endif %}
|
||||
@@ -30,30 +30,10 @@
|
||||
{% set block_id = 'scripts' %}
|
||||
{% include '_shared_store.html' %}
|
||||
<script src="{{ url_for('static', filename='js/store_page_basket.js') }}"></script>
|
||||
|
||||
{% set block_id = 'checkout' %}
|
||||
{% include '_shared_store.html' %}
|
||||
<script>
|
||||
var hashPageCurrent = "{{ model.hash_page_store_basket }}";
|
||||
var hashPageStoreCheckout = "{{ model.hash_page_store_checkout }}";
|
||||
var hashPageStoreCheckoutSession = "{{ model.hash_page_store_checkout_session }}";
|
||||
var hashStoreBasketInfo = "{{ model.hash_store_basket_info }}";
|
||||
var idOverlayInfoBilling = "#{{ model.id_overlay_info_billing }}";
|
||||
var idOverlayInfoDelivery = "#{{ model.id_overlay_info_delivery }}";
|
||||
var idContainerInfoBilling = "#{{ model.id_container_info_billing }}";
|
||||
var idContainerInfoDelivery = "#{{ model.id_container_info_delivery }}";
|
||||
var keyIdCheckout = "{{ model.key_id_checkout }}";
|
||||
var keyInfoBilling = "{{ model.key_info_billing }}";
|
||||
var keyInfoDelivery = "{{ model.key_info_delivery }}";
|
||||
var keyInfoIdentical = "{{ model.key_info_identical }}";
|
||||
var keyInfoType = "{{ model.key_info_type }}";
|
||||
var keyIsSubscription = "{{ model.key_is_subscription }}";
|
||||
var keyAddress1 = "{{ model.key_address1 }}";
|
||||
var keyAddress2 = "{{ model.key_address2 }}";
|
||||
var keyCity = "{{ model.key_city }}";
|
||||
var keyCounty = "{{ model.key_county }}";
|
||||
var keyNameFull = "{{ model.key_name_full }}";
|
||||
var keyPhoneNumber = "{{ model.key_phone_number }}";
|
||||
var keyPostcode = "{{ model.key_postcode }}";
|
||||
var keyRegion = "{{ model.key_region }}";
|
||||
var hashPageCurrent = "{{ model.HASH_PAGE_STORE_BASKET }}";
|
||||
|
||||
$(document).ready(function() {
|
||||
console.log('Hooking up store checkout success page...');
|
||||
|
||||
@@ -3,35 +3,5 @@
|
||||
{% block title %}{{ model.title }}{% endblock %}
|
||||
|
||||
{% block page_body %}
|
||||
{% set block_id = 'styles' %}
|
||||
{% include '_shared_store.html' %}
|
||||
<!-- Include Stylesheet -->
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='css/store_home.css') }}">
|
||||
|
||||
<!-- HTML content -->
|
||||
<div class="row">
|
||||
<div class="leftcolumn">
|
||||
{% for cat in model.category_list.categories %}
|
||||
{% include '_block_store_product_category.html' %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
<div id="{{ model.id_basket_container }}" class="rightcolumn">
|
||||
{% include '_block_store_basket.html' %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% set block_id = 'scripts' %}
|
||||
{% include '_shared_store.html' %}
|
||||
<!-- Include JavaScript -->
|
||||
<script src="{{ url_for('static', filename='js/store_home.js') }}"></script>
|
||||
|
||||
<script>
|
||||
var hashPageCurrent = "{{ model.hash_page_store_home }}";
|
||||
|
||||
$(document).ready(function() {
|
||||
console.log('Hooking up home page...');
|
||||
hookupStorePageHome();
|
||||
// hookupStore(); // in _shared_store.html
|
||||
});
|
||||
</script>
|
||||
{% include '_block_store_home_body.html' %}
|
||||
{% endblock %}
|
||||
@@ -30,7 +30,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="{{ model.id_basket_container }}" class="rightcolumn">
|
||||
<div id="{{ model.ID_BASKET_CONTAINER }}" class="rightcolumn">
|
||||
{% include '_block_store_basket.html' %}
|
||||
</div>
|
||||
</div>
|
||||
@@ -42,7 +42,7 @@
|
||||
|
||||
<script>
|
||||
// pass arguments from model to JS
|
||||
var hashPageCurrent = "{{ model.hash_page_store_product }}";
|
||||
var hashPageCurrent = "{{ model.HASH_PAGE_STORE_PRODUCT }}";
|
||||
|
||||
// hookup elements
|
||||
$(document).ready(function() {
|
||||
|
||||
@@ -10,33 +10,36 @@
|
||||
<script src="{{ url_for('static', filename='js/store_shared.js') }}"></script>
|
||||
<!-- Variables from Model_View_Store + model-->
|
||||
<script>
|
||||
var attrFormType = "{{ model.attr_form_type }}";
|
||||
var attrIdPermutation = "{{ model.attr_id_permutation }}";
|
||||
var attrIdProduct = "{{ model.attr_id_product }}";
|
||||
var attrIdProductCategory = "{{ model.attr_id_product_category }}";
|
||||
var flagBasketItemDelete = "{{ model.flag_basket_item_delete }}";
|
||||
var flagBtnBasketAdd = "{{ model.flag_btn_basket_add }}";
|
||||
var flagBtnBuyNow = "{{ model.flag_btn_buy_now }}";
|
||||
var hashStoreBasketAdd = "{{ model.hash_store_basket_add }}";
|
||||
var hashStoreBasketDelete = "{{ model.hash_store_basket_delete }}";
|
||||
var hashStoreBasketEdit = "{{ model.hash_store_basket_edit }}";
|
||||
var hashStoreBasketLoad = "{{ model.hash_store_basket_load }}";
|
||||
var hashStoreSelectCurrency = "{{ model.hash_store_select_currency }}";
|
||||
var hashStoreSelectDeliveryRegion = "{{ model.hash_store_select_delivery_region }}";
|
||||
var hashStoreSetIsIncludedVAT = "{{ model.hash_store_set_is_included_VAT }}";
|
||||
var hashPageStoreBasket = "{{ model.hash_page_store_basket }}";
|
||||
var idBasket = "#{{ model.id_basket }}";
|
||||
var idBasketContainer = "#{{ model.id_basket_container }}";
|
||||
var idBasketTotal = "#{{ model.id_basket_total }}";
|
||||
var idBtnCheckout = "#{{ model.id_btn_checkout }}";
|
||||
var idLabelBasketEmpty = "#{{ model.id_label_basket_empty }}";
|
||||
var attrFormType = "{{ model.ATTR_FORM_TYPE }}";
|
||||
var attrIdPermutation = "{{ model.ATTR_ID_PERMUTATION }}";
|
||||
var attrIdProduct = "{{ model.ATTR_ID_PRODUCT }}";
|
||||
var attrIdProductCategory = "{{ model.ATTR_ID_PRODUCT_CATEGORY }}";
|
||||
var flagBasketItemDelete = "{{ model.FLAG_BASKET_ITEM_DELETE }}";
|
||||
var flagBtnBasketAdd = "{{ model.FLAG_BTN_BASKET_ADD }}";
|
||||
var flagBtnBuyNow = "{{ model.FLAG_BTN_BUY_NOW }}";
|
||||
var hashStoreBasketAdd = "{{ model.HASH_STORE_BASKET_ADD }}";
|
||||
var hashStoreBasketDelete = "{{ model.HASH_STORE_BASKET_DELETE }}";
|
||||
var hashStoreBasketEdit = "{{ model.HASH_STORE_BASKET_EDIT }}";
|
||||
var hashStoreBasketLoad = "{{ model.HASH_STORE_BASKET_LOAD }}";
|
||||
var hashStoreSetCurrency = "{{ model.HASH_STORE_SET_CURRENCY }}";
|
||||
var hashStoreSetRegion = "{{ model.HASH_STORE_SET_REGION }}";
|
||||
var hashStoreSetIsIncludedVAT = "{{ model.HASH_STORE_SET_IS_INCLUDED_VAT }}";
|
||||
var hashPageStoreBasket = "{{ model.HASH_PAGE_STORE_BASKET }}";
|
||||
var idBasket = "#{{ model.ID_BASKET }}";
|
||||
var idBasketContainer = "#{{ model.ID_BASKET_CONTAINER }}";
|
||||
var idBasketTotal = "#{{ model.ID_BASKET_TOTAL }}";
|
||||
var idBtnCheckout = "#{{ model.ID_BUTTON_CHECKOUT }}";
|
||||
var idCurrency = "#{{ model.ID_CURRENCY }}";
|
||||
var idLabelBasketEmpty = "#{{ model.ID_LABEL_BASKET_EMPTY }}";
|
||||
var idRegionDelivery = "#{{ model.ID_REGION_DELIVERY }}";
|
||||
var keyIdCurrency = "{{ model.KEY_ID_CURRENCY }}";
|
||||
var keyIdPermutation = "{{ model.key_id_permutation }}";
|
||||
var keyIdProduct = "{{ model.key_id_product }}";
|
||||
var keyItems = "{{ model.KEY_ITEMS }}";
|
||||
var keyIdPermutation = "{{ model.KEY_ID_PERMUTATION }}";
|
||||
var keyIdProduct = "{{ model.KEY_ID_PRODUCT }}";
|
||||
var keyIdRegionDelivery = "{{ model.KEY_ID_REGION_DELIVERY }}";
|
||||
var keyIsIncludedVAT = "{{ model.KEY_IS_INCLUDED_VAT }}";
|
||||
var typeFormBasketAdd = "{{ model.type_form_basket_add }}";
|
||||
var typeFormBasketEdit = "{{ model.type_form_basket_edit }}";
|
||||
var typeFormBasketAdd = "{{ model.TYPE_FORM_BASKET_ADD }}";
|
||||
var typeFormBasketEdit = "{{ model.TYPE_FORM_BASKET_EDIT }}";
|
||||
|
||||
if (!isEmpty({{ model.basket.items }})) {
|
||||
localStorage.setItem(keyBasket, JSON.parse(JSON.stringify({'items': "{{ model.basket.items }}"})));
|
||||
@@ -48,4 +51,30 @@
|
||||
});
|
||||
|
||||
</script>
|
||||
{% elif block_id == 'checkout' %}
|
||||
<!-- Variables from Model_View_Store + model-->
|
||||
<script>
|
||||
var hashPageStoreCheckout = "{{ model.HASH_PAGE_STORE_CHECKOUT }}";
|
||||
var hashPageStoreCheckoutSession = "{{ model.HASH_PAGE_STORE_CHECKOUT_SESSION }}";
|
||||
var hashStoreBasketInfo = "{{ model.HASH_STORE_BASKET_INFO }}";
|
||||
var idOverlayInfoBilling = "#{{ model.ID_OVERLAY_INFO_BILLING }}";
|
||||
var idOverlayInfoDelivery = "#{{ model.ID_OVERLAY_INFO_DELIVERY }}";
|
||||
var idContainerInfoBilling = "#{{ model.ID_CONTAINER_INFO_BILLING }}";
|
||||
var idContainerInfoDelivery = "#{{ model.ID_CONTAINER_INFO_DELIVERY }}";
|
||||
var keyIdCheckout = "{{ model.KEY_ID_CHECKOUT }}";
|
||||
var keyInfoBilling = "{{ model.KEY_INFO_BILLING }}";
|
||||
var keyInfoDelivery = "{{ model.KEY_INFO_DELIVERY }}";
|
||||
var keyInfoIdentical = "{{ model.KEY_INFO_IDENTICAL }}";
|
||||
var keyInfoType = "{{ model.KEY_INFO_TYPE }}";
|
||||
var keyIsSubscription = "{{ model.KEY_IS_SUBSCRIPTION }}";
|
||||
var keyAddress1 = "{{ model.KEY_ADDRESS1 }}";
|
||||
var keyAddress2 = "{{ model.KEY_ADDRESS2 }}";
|
||||
var keyCity = "{{ model.KEY_CITY }}";
|
||||
var keyCounty = "{{ model.KEY_COUNTY }}";
|
||||
var keyNameFull = "{{ model.KEY_NAME_FULL }}";
|
||||
var keyPhoneNumber = "{{ model.KEY_PHONE_NUMBER }}";
|
||||
var keyPostcode = "{{ model.KEY_POSTCODE }}";
|
||||
var keyRegion = "{{ model.KEY_REGION }}";
|
||||
var keyUrlCheckout = "{{ model.KEY_URL_CHECKOUT }}";
|
||||
</script>
|
||||
{% endif %}
|
||||
@@ -10,13 +10,17 @@
|
||||
<script src="https://code.jquery.com/jquery-3.7.1.js"></script> <!-- Include jQuery from a CDN -->
|
||||
|
||||
<script>
|
||||
var attrTextCollapsed = "{{ model.ATTR_TEXT_COLLAPSED }}";
|
||||
var attrTextExpanded = "{{ model.ATTR_TEXT_EXPANDED }}";
|
||||
var flagBtnOverlayClose = "{{ model.FLAG_BTN_OVERLAY_CLOSE }}";
|
||||
var flagBtnSubmit = "{{ model.FLAG_BTN_SUBMIT }}";
|
||||
var flagCard = "{{ model.FLAG_CARD }}";
|
||||
var flagCollapsed = "{{ model.FLAG_COLLAPSED }}";
|
||||
var flagCollapsible = "{{ model.FLAG_COLLAPSIBLE }}";
|
||||
var flagColumn = "{{ model.FLAG_COLUMN }}";
|
||||
var flagContainer = "{{ model.FLAG_CONTAINER }}";
|
||||
var flagContainerInput = "{{ model.FLAG_CONTAINER_INPUT }}";
|
||||
var flagExpanded = "{{ model.FLAG_EXPANDED }}";
|
||||
var flagRow = "{{ model.FLAG_ROW }}";
|
||||
var flagScrollable = "{{ model.FLAG_SCROLLABLE }}";
|
||||
var flagBtnOverlayClose = "{{ model.FLAG_BTN_OVERLAY_CLOSE }}";
|
||||
@@ -64,18 +68,22 @@
|
||||
<div class="container column">
|
||||
<a id="{{ model.ID_NAV_HOME }}">Home</a> <!-- href="{{ url_for('home') }}" -->
|
||||
</div>
|
||||
<!--
|
||||
<div class="container column">
|
||||
<a id="{{ model.ID_NAV_SERVICES }}">Services</a>
|
||||
</div>
|
||||
<div class="container column">
|
||||
<a id="{{ model.ID_NAV_TECHNOLOGIES }}">Technologies</a>
|
||||
</div>
|
||||
-->
|
||||
<div class="container column">
|
||||
<a id="{{ model.ID_NAV_STORE_HOME }}">Store</a>
|
||||
</div>
|
||||
<!--
|
||||
<div class="container column">
|
||||
<a id="{{ model.ID_NAV_CONTACT }}">Contact</a> <!-- href="{{ url_for('contact') }}" -->
|
||||
<a id="{{ model.ID_NAV_CONTACT }}">Contact</a> <!-- href="{{ url_for('contact') }}" --
|
||||
</div>
|
||||
-->
|
||||
{% if model.is_page_store %}
|
||||
<div class="container column">
|
||||
<!-- <a href="{ url_ for('create_price_dummy') }">Create template price</a> -->
|
||||
@@ -83,7 +91,7 @@
|
||||
{{ model.form_is_included_VAT.hidden_tag() }}
|
||||
<div class="container-input">
|
||||
{{ model.form_is_included_VAT.is_included.label }}
|
||||
{{ model.form_is_included_VAT.is_included() }}
|
||||
{{ model.form_is_included_VAT.is_included( checked = model.is_included_VAT ) }}
|
||||
{% for error in model.form_is_included_VAT.is_included.errors %}
|
||||
<p class="error">{{ error }}</p>
|
||||
{% endfor %}
|
||||
|
||||
Reference in New Issue
Block a user