Created
August 14, 2019 18:32
-
-
Save aatronco/2debc27e5810cb4467bab0c8da901ce8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var remove_payment = function(data) { | |
| var order_product_id = payment_cost_order_product_id(data); | |
| Jumpseller.updateCart(order_product_id, 0); // no payment cost on the order. | |
| } | |
| function payment_cost_order_product_id(cart_json) { | |
| var id = null; | |
| $.each(cart_json.products, function(i, order_product) { | |
| if (order_product.product_id == productId) { // product for adding payment cost. You need to create a virtual product with the additional price. The ID is the number in the URL of the product in the admin panel. | |
| id = order_product.id; | |
| } | |
| }); | |
| return id; // return order_product.id if found | |
| } | |
| var productId = "3577772" | |
| var domingoId = "6127680" | |
| var feriadoId = "6127681" | |
| function getWeekDay(date) { | |
| //Create an array containing each day, starting with Sunday. | |
| var weekdays = new Array( | |
| "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" | |
| ); | |
| //Use the getDay() method to get the day. | |
| var day = date.getDay(); | |
| //Return the element that corresponds to that index. | |
| return weekdays[day]; | |
| } | |
| document.getElementById("order_other_fecha_de_entrega_de_regalo").addEventListener("change", function() { | |
| var input = this.value; | |
| var dateEntered = new Date(input); | |
| var dayName = getWeekDay(dateEntered); | |
| console.log(getWeekDay(dateEntered)); | |
| if (dayName == "Sunday") { | |
| console.log("Agregar"); | |
| Jumpseller.getCart({ | |
| callback: remove_payment | |
| }); | |
| Jumpseller.addProductToCart(productId, 1, { | |
| "Variant": domingoId | |
| }) | |
| } else { | |
| console.log("Remover"); | |
| Jumpseller.getCart({ | |
| callback: remove_payment | |
| }) | |
| } | |
| }); | |
| function payment_cost_order_product_id(cart_json) { | |
| var id = null; | |
| $.each(cart_json.products, function(i, order_product) { | |
| if (order_product.product_id == productId) { // product for adding payment cost. You need to create a virtual product with the additional price. The ID is the number in the URL of the product in the admin panel. | |
| id = order_product.id; | |
| } | |
| }); | |
| return id; // return order_product.id if found | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment