Advertisement
rijarob

Use PO on Coupon

May 15th, 2017
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.75 KB | None | 0 0
  1. ​<!-- goes in checkout template -->
  2.  
  3. <!-- have to remove config.supports_purchase_order on testing because can only enable with live -->
  4. <!-- put config.supports_purchase_order in {% if payment_info_required and po_coupon %} when live -->
  5.  
  6. {% block payment_method %}
  7. {% set po_coupon = false %}
  8. {% if coupons.NOCC %}
  9. {% set po_coupon = true %}
  10. {% endif %}
  11.  
  12. {% if payment_info_required and po_coupon %}
  13. {% set config = config|merge({ supports_pay_with_plastic: false, supports_purchase_order: true}) %}
  14. {% set payment_method_type = "purchase_order" %}
  15. {% else %}
  16. {% set config = config|merge({ supports_pay_with_plastic: true, supports_purchase_order: false}) %}
  17. {% endif %}
  18. {{ parent() }}
  19. {% endblock %}
  20.  
  21. <!-- If I add it while in the checkout, it changes the cc to po -->
  22. <!-- If I remove it in the checkout, then readd it, I have to refresh the page -->
  23.  
  24. <!-- template footer -->
  25. <!-- if coupon is removed from cart, cc fields appear, if coupon added back, this script doesn't execute -->
  26. {% if context == "checkout" and coupons.NOCC %}
  27. <script>
  28.  
  29. FC.client.on("ready.done", checkPO);
  30. FC.client.on("cart-item-remove.done", checkPO);
  31. FC.client.on("cart-item-quantity-update.done", checkPO);
  32. FC.client.on("cart-coupon-add.done", checkPO);
  33. FC.client.on("customer-login.done", checkPO);
  34.  
  35.  
  36. function checkPO(customer_po) {
  37. var customer_po = $("#customer_email").val();
  38. console.log(customer_po);
  39. $("#fc-payment-method-purchase-order").hide();
  40. $("#fc-icon-lock-large").hide();
  41. $("#fc-payment-method-purchase-order").after("<div class=col-md-2></div><b>No payment method required</b>");
  42. $("#purchase_order").val(customer_po);
  43. FC.cart.render();
  44. }
  45. </script>
  46.  
  47. {% endif %}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement