diff --git a/__pycache__/app.cpython-311.pyc b/__pycache__/app.cpython-311.pyc
index ff497394..a2994b7e 100644
Binary files a/__pycache__/app.cpython-311.pyc and b/__pycache__/app.cpython-311.pyc differ
diff --git a/__pycache__/forms.cpython-311.pyc b/__pycache__/forms.cpython-311.pyc
index dda69191..dc8338bb 100644
Binary files a/__pycache__/forms.cpython-311.pyc and b/__pycache__/forms.cpython-311.pyc differ
diff --git a/app.py b/app.py
index 82d77974..24eb2953 100644
--- a/app.py
+++ b/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) # "
Boobs
"
- # 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) # "Boobs
"
+ 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=regionId=&¤cyId=', methods=['GET']) # &
-def store_product(permutation_id, region_id, currency_id):
+@app.route('/store/product?permutationId=regionId=&¤cyId=&isIncludedVAT=', methods=['GET']) # &
+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'])
diff --git a/business_objects/__pycache__/basket.cpython-311.pyc b/business_objects/__pycache__/basket.cpython-311.pyc
index 0c1f504e..c6901b7b 100644
Binary files a/business_objects/__pycache__/basket.cpython-311.pyc and b/business_objects/__pycache__/basket.cpython-311.pyc differ
diff --git a/business_objects/__pycache__/category.cpython-311.pyc b/business_objects/__pycache__/category.cpython-311.pyc
index 65343486..9767b109 100644
Binary files a/business_objects/__pycache__/category.cpython-311.pyc and b/business_objects/__pycache__/category.cpython-311.pyc differ
diff --git a/business_objects/__pycache__/product.cpython-311.pyc b/business_objects/__pycache__/product.cpython-311.pyc
index f2d0372b..547dcc04 100644
Binary files a/business_objects/__pycache__/product.cpython-311.pyc and b/business_objects/__pycache__/product.cpython-311.pyc differ
diff --git a/business_objects/basket.py b/business_objects/basket.py
index 3ee058f5..5468f374 100644
--- a/business_objects/basket.py
+++ b/business_objects/basket.py
@@ -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:
diff --git a/business_objects/category.py b/business_objects/category.py
index c696cecd..6ec8706a 100644
--- a/business_objects/category.py
+++ b/business_objects/category.py
@@ -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():
diff --git a/business_objects/product.py b/business_objects/product.py
index 5060058d..8bf7d8e5 100644
--- a/business_objects/product.py
+++ b/business_objects/product.py
@@ -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):
diff --git a/datastores/__pycache__/datastore_store.cpython-311.pyc b/datastores/__pycache__/datastore_store.cpython-311.pyc
index c081b60b..bd7618ed 100644
Binary files a/datastores/__pycache__/datastore_store.cpython-311.pyc and b/datastores/__pycache__/datastore_store.cpython-311.pyc differ
diff --git a/datastores/datastore_store.py b/datastores/datastore_store.py
index 4c876d54..3f1f1f01 100644
--- a/datastores/datastore_store.py
+++ b/datastores/datastore_store.py
@@ -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
\ No newline at end of file
diff --git a/forms.py b/forms.py
index 7154480c..6e3b5ebd 100644
--- a/forms.py
+++ b/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')
\ No newline at end of file
+ id_id_currency = 'id_currency'
+ id_currency = SelectField('Currency', id='id_currency')
\ No newline at end of file
diff --git a/models/__pycache__/model_view_base.cpython-311.pyc b/models/__pycache__/model_view_base.cpython-311.pyc
index 1e0d7cf7..5d8e3f3c 100644
Binary files a/models/__pycache__/model_view_base.cpython-311.pyc and b/models/__pycache__/model_view_base.cpython-311.pyc differ
diff --git a/models/__pycache__/model_view_store.cpython-311.pyc b/models/__pycache__/model_view_store.cpython-311.pyc
index b1396928..3985ff5d 100644
Binary files a/models/__pycache__/model_view_store.cpython-311.pyc and b/models/__pycache__/model_view_store.cpython-311.pyc differ
diff --git a/models/__pycache__/model_view_store_basket.cpython-311.pyc b/models/__pycache__/model_view_store_basket.cpython-311.pyc
index 86c02f96..8048bf9e 100644
Binary files a/models/__pycache__/model_view_store_basket.cpython-311.pyc and b/models/__pycache__/model_view_store_basket.cpython-311.pyc differ
diff --git a/models/__pycache__/model_view_store_checkout.cpython-311.pyc b/models/__pycache__/model_view_store_checkout.cpython-311.pyc
index e3273334..3854ddaa 100644
Binary files a/models/__pycache__/model_view_store_checkout.cpython-311.pyc and b/models/__pycache__/model_view_store_checkout.cpython-311.pyc differ
diff --git a/models/__pycache__/model_view_store_checkout_success.cpython-311.pyc b/models/__pycache__/model_view_store_checkout_success.cpython-311.pyc
index fff1c74e..67140574 100644
Binary files a/models/__pycache__/model_view_store_checkout_success.cpython-311.pyc and b/models/__pycache__/model_view_store_checkout_success.cpython-311.pyc differ
diff --git a/models/__pycache__/model_view_store_home.cpython-311.pyc b/models/__pycache__/model_view_store_home.cpython-311.pyc
index c2638ec9..f2c9f472 100644
Binary files a/models/__pycache__/model_view_store_home.cpython-311.pyc and b/models/__pycache__/model_view_store_home.cpython-311.pyc differ
diff --git a/models/__pycache__/model_view_store_product.cpython-311.pyc b/models/__pycache__/model_view_store_product.cpython-311.pyc
index 3b140ea4..c8331e86 100644
Binary files a/models/__pycache__/model_view_store_product.cpython-311.pyc and b/models/__pycache__/model_view_store_product.cpython-311.pyc differ
diff --git a/models/model_view_base.py b/models/model_view_base.py
index 0c0a5c81..4251628b 100644
--- a/models/model_view_base.py
+++ b/models/model_view_base.py
@@ -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'
diff --git a/models/model_view_store.py b/models/model_view_store.py
index 57f4510e..6737f43b 100644
--- a/models/model_view_store.py
+++ b/models/model_view_store.py
@@ -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
diff --git a/models/model_view_store_basket.py b/models/model_view_store_basket.py
index cd4819ef..7426e43c 100644
--- a/models/model_view_store_basket.py
+++ b/models/model_view_store_basket.py
@@ -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
diff --git a/models/model_view_store_checkout.py b/models/model_view_store_checkout.py
index 6a072fc0..73652ccd 100644
--- a/models/model_view_store_checkout.py
+++ b/models/model_view_store_checkout.py
@@ -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")
diff --git a/models/model_view_store_checkout_success.py b/models/model_view_store_checkout_success.py
index 6705ae75..01f7daed 100644
--- a/models/model_view_store_checkout_success.py
+++ b/models/model_view_store_checkout_success.py
@@ -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)
\ No newline at end of file
diff --git a/models/model_view_store_home.py b/models/model_view_store_home.py
index 5cbed4c5..ad2925d9 100644
--- a/models/model_view_store_home.py
+++ b/models/model_view_store_home.py
@@ -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)
"""
diff --git a/models/model_view_store_product.py b/models/model_view_store_product.py
index 23bc705a..633f6baf 100644
--- a/models/model_view_store_product.py
+++ b/models/model_view_store_product.py
@@ -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")}')
diff --git a/static/css/shared.css b/static/css/shared.css
index 1f64ed2b..47069acf 100644
--- a/static/css/shared.css
+++ b/static/css/shared.css
@@ -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 {
diff --git a/static/js/shared.js b/static/js/shared.js
index 70073b3f..139fe764 100644
--- a/static/js/shared.js
+++ b/static/js/shared.js
@@ -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]);
diff --git a/static/js/store_shared.js b/static/js/store_shared.js
index 693b0c47..fb5aac3e 100644
--- a/static/js/store_shared.js
+++ b/static/js/store_shared.js
@@ -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);
}
diff --git a/static/sql/700_p_shop_get_many_product.sql b/static/sql/700_p_shop_get_many_product.sql
index e0ca4462..ed335da2 100644
--- a/static/sql/700_p_shop_get_many_product.sql
+++ b/static/sql/700_p_shop_get_many_product.sql
@@ -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
diff --git a/templates/_block_store_basket.html b/templates/_block_store_basket.html
index 3e53f581..11395991 100644
--- a/templates/_block_store_basket.html
+++ b/templates/_block_store_basket.html
@@ -1,6 +1,6 @@
{% set show_delivery_option = False %}
-
-
+
{% include '_block_store_basket.html' %}
@@ -42,7 +42,7 @@
+{% elif block_id == 'checkout' %}
+
+
{% endif %}
\ No newline at end of file
diff --git a/templates/layout.html b/templates/layout.html
index bca6b428..7d8c2aff 100644
--- a/templates/layout.html
+++ b/templates/layout.html
@@ -10,13 +10,17 @@