Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

My Awesome Cart Tracker #3

Open
bilalamjad837 opened this issue Oct 11, 2019 · 0 comments
Open

My Awesome Cart Tracker #3

bilalamjad837 opened this issue Oct 11, 2019 · 0 comments

Comments

@bilalamjad837
Copy link

When i click tracker button the the Updateorder shows
{"status": "success", "updates": [{"text": "The order has been placed"}], "itemsJson": "{"pr1":[1,"PEPSI 2 "]}"}

in another page

my email: [email protected]

*** tracker html code**

{% extends 'Supply_Chain/basic.html' %}
{% block title%} My Awesome Cart Tracker{% endblock %}
{% block body %}

Enter your Order Id and Email address to track your order

{% csrf_token %}
Order Id
Email
Track Order

Your Order Status

    Enter your order Id and Email and click Track Order to find details about your order!

Your Order Details

{% endblock %} {% block js %} <script> $('#trackerForm').submit(function(event) { $('#items').empty(); var formData = { 'orderId': $('input[name=orderId]').val(), 'email': $('input[name=email]').val(), 'csrfmiddlewaretoken': $('input[name=csrfmiddlewaretoken]').val() }; $.ajax({ type: 'POST', url: '/PepsiProduct/tracker/', data: formData, encode: true }) .done(function(data) { $('#citems').empty(); console.log(data) data = JSON.parse(data); if (data['status'] == 'success') { updates = data['updates']; for (i = 0; i < updates.length; i++) { let text = updates[i]['text']; let time = updates[i]['time']; mystr = `
  • ${text} ${time}
  • ` $('#items').append(mystr); } // Fill in the order details cart = JSON.parse(data['itemsJson']); console.log(cart); for (item in cart) { let name = cart[item][1]; let qty = cart[item][0]; mystr = `
  • ${name} ${qty}
  • ` $('#citems').append(mystr); } } else { mystr = `
  • Sorry, We are not able to fetch this order id and email. Make sure to type correct order Id and email
  • ` $('#items').append(mystr); $('#citems').append(mystr); } }); event.preventDefault(); }); </script> {% endblock %}
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    None yet
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant