Skip to content

Commit

Permalink
feat: better success page, also custom success page
Browse files Browse the repository at this point in the history
Closes #15
  • Loading branch information
NagariaHussain committed Nov 8, 2023
1 parent e83ac40 commit dfd0649
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
"categories_synced",
"custom_template_section",
"use_custom_product_view_template",
"custom_product_view_template"
"custom_product_view_template",
"override_success_page",
"success_page_route"
],
"fields": [
{
Expand Down Expand Up @@ -74,7 +76,7 @@
{
"fieldname": "custom_template_section",
"fieldtype": "Section Break",
"label": "Custom Template"
"label": "Storefront Customisations"
},
{
"fieldname": "invoicing_section",
Expand Down Expand Up @@ -102,12 +104,26 @@
"fieldtype": "Code",
"label": "Message",
"options": "HTML"
},
{
"default": "0",
"fieldname": "override_success_page",
"fieldtype": "Check",
"label": "Override Success Page?"
},
{
"depends_on": "eval:doc.override_success_page==1",
"description": "We will pass Order ID as query parameter to this route <pre>?order_id=ORDER-XX-YYYY-ZZZ</pre>",
"fieldname": "success_page_route",
"fieldtype": "Data",
"label": "Success Page Route",
"mandatory_depends_on": "eval:doc.override_success_page==1"
}
],
"index_web_pages_for_search": 1,
"issingle": 1,
"links": [],
"modified": "2023-11-06 15:40:32.771066",
"modified": "2023-11-08 22:27:37.903271",
"modified_by": "Administrator",
"module": "Printrov Merch Store",
"name": "Printrove Settings",
Expand Down
1 change: 1 addition & 0 deletions printrov_merch_store/public/image/purchase_success.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion printrov_merch_store/www/store/checkout.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
}
}).then(({ message: store_order_id }) => {
// redirect to success page
window.location = `/store/success?store_order_id=${store_order_id}`
window.location = `{{ success_page_route }}?store_order_id=${store_order_id}`
}).catch(() => {
alert("Error placing your order!")
})
Expand Down
7 changes: 7 additions & 0 deletions printrov_merch_store/www/store/checkout.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,10 @@ def get_context(context):
f"/login?redirect-to={frappe.request.url}"
)
raise frappe.Redirect

success_page_route = "/store/success"
printrove_settings = frappe.get_cached_doc("Printrove Settings")
if printrove_settings.override_success_page:
success_page_route = printrove_settings.success_page_route

context.success_page_route = success_page_route
20 changes: 18 additions & 2 deletions printrov_merch_store/www/store/success.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
{% extends "templates/web.html" %}

{% block page_content %}
{% set order_id = frappe.form_dict.get("store_order_id") %}
<h2>Payment Successful. Your order has been placed with order id: {{ order_id }}</h2>

{% set order_id = frappe.form_dict.get("store_order_id") %}
{% set courier_name = frappe.db.get_value("Store Order", order_id, "courier_name") %}

<div class="container-fluid mt-14">
<img class="px-5 mb-10" src="/assets/printrov_merch_store/image/purchase_success.svg">

<div>
<h2 class="text-center">Order Successful 🎉</h2>
<p class="text-center text-muted">The payment was successful!</p>
<hr>
<div class="mt-8">
<p>You will be notified once your order is shipped.</p>
<p class="mb-0"><strong>Reference ID:</strong> <span>{{ order_id }}</span></p>
<p><strong>Courier Name:</strong> <span>{{ courier_name }}</span></p>
</div>
</div>
</div>
{% endblock %}

0 comments on commit dfd0649

Please sign in to comment.