Skip to content
9 changes: 5 additions & 4 deletions webshop/patches/add_homepage_field.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import frappe
from frappe.custom.doctype.custom_field.custom_field import create_custom_fields


def execute():
if not frappe.db.exists("Custom Field",
{"fieldname": "products", "dt": "Homepage"}
):
if not frappe.db.exists("DocType", "Homepage"):
return
if not frappe.db.exists("Custom Field", {"fieldname": "products", "dt": "Homepage"}):
custom_fields = {
"Homepage": [
dict(
Expand All @@ -29,4 +30,4 @@ def execute():
],
}

create_custom_fields(custom_fields)
create_custom_fields(custom_fields)
24 changes: 12 additions & 12 deletions webshop/templates/includes/cart/cart_address.html
Original file line number Diff line number Diff line change
Expand Up @@ -70,38 +70,38 @@

$('.btn-new-address').click(() => {
const d = new frappe.ui.Dialog({
title: __('New Address'),
title: {{ _("New Address") }},
fields: [
{
label: __('Address Title'),
label: {{ _("Address Title") }},
fieldname: 'address_title',
fieldtype: 'Data',
reqd: 1
},
{
label: __('Address Line 1'),
label: {{ _("Address Line 1") }},
fieldname: 'address_line1',
fieldtype: 'Data',
reqd: 1
},
{
label: __('Address Line 2'),
label: {{ _("Address Line 2") }},
fieldname: 'address_line2',
fieldtype: 'Data'
},
{
label: __('City/Town'),
label: {{ _("City/Town") }},
fieldname: 'city',
fieldtype: 'Data',
reqd: 1
},
{
label: __('State'),
label: {{ _("State") }},
fieldname: 'state',
fieldtype: 'Data'
},
{
label: __('Country'),
label: {{ _("Country") }},
fieldname: 'country',
fieldtype: 'Link',
options: 'Country',
Expand All @@ -114,7 +114,7 @@
width: "50%"
},
{
label: __('Address Type'),
label: {{ _("Address Type") }},
fieldname: 'address_type',
fieldtype: 'Select',
options: [
Expand All @@ -124,18 +124,18 @@
reqd: 1
},
{
label: __('Postal Code'),
label: {{ _("Postal Code") }},
fieldname: 'pincode',
fieldtype: 'Data'
},
{
fieldname: "phone",
fieldtype: "Data",
label: "Phone",
label: {{ _("Phone") }},
reqd: 1
},
],
primary_action_label: __('Save'),
primary_action_label: {{ _("Save") }},
primary_action: (values) => {
frappe.call('webshop.webshop.shopping_cart.cart.add_new_address', { doc: values })
.then(r => {
Expand Down Expand Up @@ -261,4 +261,4 @@
d.show();
});
});
</script>
</script>
4 changes: 2 additions & 2 deletions webshop/templates/includes/cart/cart_items_total.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
<tr>
<th></th>
<th class="text-left item-grand-total" colspan="1">
{{ _("Total") }}
{{ _("Net Total") }}
</th>
<th class="text-left item-grand-total totals" colspan="3">
{{ doc.get_formatted("total") }}
</th>
</tr>
</tr>
16 changes: 8 additions & 8 deletions webshop/templates/includes/macros.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ <h3>{{ _(section.name) }}</h3>
<div itemprop="image" class="card-body">
<h5 class="card-title">{{ _(card.title) }}</h5>
<p class="card-subtitle mb-2 text-muted">{{ _(card.subtitle) or '' }}</p>
<p class="card-text">{{ card.content or '' | truncate(140, True) }}</p>
<p class="card-text">{{ _(card.content) or '' | truncate(140, True) }}</p>
</div>
<div class="card-body flex-grow-0">
<a href="{{ card.route }}" class="card-link">{{ _('More details') }}</a>
Expand Down Expand Up @@ -128,7 +128,7 @@ <h5 class="card-title">{{ _(card.title) }}</h5>
<div class="mt-4">
<a href="/{{ item.route or '#' }}">
<div class="product-title">
{{ title or '' }}
{{ _(title) or '' }}
</div>
</a>
</div>
Expand All @@ -138,7 +138,7 @@ <h5 class="card-title">{{ _(card.title) }}</h5>
</div>
{% else %}
{% if template != "Product Card" %}
<div class="product-category">{{ item.item_group or '' }}</div>
<div class="product-category">{{ _(item.item_group) or '' }}</div>
{% endif %}
{% endif %}
</div>
Expand Down Expand Up @@ -233,23 +233,23 @@ <h2 style="font-size: 2rem;">
{{ average_rating or 0 }}
</h2>
<div class="mb-2" style="margin-top: -.5rem;">
{{ frappe.utils.cstr(total_reviews or 0) + " " + _("ratings") }}
{{ frappe.utils.cstr(total_reviews or 0) }} {{ _("ratings") }}
</div>

<!-- Ratings Summary -->
{% if reviews %}
{% set rating_title = frappe.utils.cstr(average_rating) + " " + _("out of 5") if not for_summary else ''%}
{{ ratings_with_title(average_whole_rating/5, rating_title, "md", "rating-summary-title", for_summary) }}
{% set rating_title = frappe.utils.cstr(average_rating) }} {{ _("out of 5") if not for_summary else ''%}
{{ ratings_with_title(average_whole_rating, rating_title, "md", "rating-summary-title", for_summary) }}
{% endif %}

<div class="mt-2">{{ frappe.utils.cstr(average_rating or 0) + " " + _("out of 5") }}</div>
<div class="mt-2">{{ frappe.utils.cstr(average_rating or 0) }} {{ _("out of 5") }}</div>
</div>

<!-- Rating Progress Bars -->
<div class="rating-progress-bar-section col-4 ml-4">
{% for percent in reviews_per_rating %}
<div class="col-sm-4 small rating-bar-title">
{{ loop.index }} star
{{ loop.index }} {{ _("star") }}
</div>
<div class="row">
<div class="col-md-7">
Expand Down
3 changes: 3 additions & 0 deletions webshop/webshop/doctype/override_doctype/item_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ def get_context(self, context):

return context

def has_website_permission(self, ptype, user, verbose=False):
return ptype == "read"

def get_item_for_list_in_html(context):
# add missing absolute link in files
# user may forget it during upload
Expand Down
12 changes: 11 additions & 1 deletion webshop/webshop/variant_selector/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,16 @@ def get_attributes_and_values(item_code):
for iv in item_attribute_values:
ordered_attribute_value_map.setdefault(iv.parent, []).append(iv.attribute_value)

"""Numeric attributes are not stored in the Item Attribute Value table.
However, they are included in valid_options. If they are not found in ordered_attribute_value_map
sort and add them to it. This does not include the entire range if there is no
product associated with specific number. Only possible values are returned.
"""
for attr_name in attribute_list:
if attr_name not in ordered_attribute_value_map:
numeric_list = sorted([i for i in valid_options[attr_name] if i.replace(".","").isnumeric()], key=float)
ordered_attribute_value_map[attr_name] = numeric_list

# build attribute values in idx order
for attr in attributes:
valid_attribute_values = valid_options.get(attr.attribute, [])
Expand Down Expand Up @@ -246,4 +256,4 @@ def get_item_variant_price_dict(item_code, cart_settings):
)
return {"price": price}

return None
return None
2 changes: 1 addition & 1 deletion webshop/webshop/web_template/hero_slider/hero_slider.json
Original file line number Diff line number Diff line change
Expand Up @@ -282,4 +282,4 @@
"standard": 1,
"template": "",
"type": "Section"
}
}
8 changes: 4 additions & 4 deletions webshop/www/all-products/index.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{% from "webshop/templates/includes/macros.html" import attribute_filter_section, field_filter_section, discount_range_filters %}
{% extends "templates/web.html" %}

{% block title %}{{ _('All Products') }}{% endblock %}
{% block title %}{{ _("All Products") }}{% endblock %}
{% block header %}
<div class="mb-6">{{ _('All Products') }}</div>
<div class="mb-6">{{ _("All Products") }}</div>
{% endblock header %}

{% block page_content %}
Expand All @@ -22,12 +22,12 @@
</div>
<!-- field filters -->
{% if field_filters %}
{{ field_filter_section(field_filters) }}
{{ _(field_filter_section(field_filters)) }}
{% endif %}

<!-- attribute filters -->
{% if attribute_filters %}
{{ attribute_filter_section(attribute_filters) }}
{{ _(attribute_filter_section(attribute_filters)) }}
{% endif %}
</div>

Expand Down