View difference between Paste ID: uvQy017u and uqq4iEuE
SHOW: | | - or go back to the newest paste.
1
{% if context == "cart" or context == "checkout" %}
2
<script>
3
FC.client.on("render.done", function() {
4-
    var message = '<p>Note: Add 1-2 business days for processing.</p>';
4+
    var message = '<p>Message to be shown if there is more than 1 of each type of product by category.</p>',
5
		both_categories = false,
6-
    if ($(".shipping-note").length == 0 && FC.json.shipping_address.shipping_results.length > 0) {
6+
		number_default = 0,
7
		number_perishables = 0;
8
9
	for (var i=0; i<FC.json.items.length; i++) {
10
		if (FC.json.items[i].category == "DEFAULT") {
11
			number_default = number_default + FC.json.items[i].quantity;
12
		}
13
		if (FC.json.items[i].category == "Perishables") {
14
			number_perishables = number_perishables + FC.json.items[i].quantity;
15
		}
16
	}
17
18
	if (number_default > 1 && number_perishables > 1) {
19
		both_categories = true;
20
	}
21
22
    if ($(".shipping-note").length == 0 && FC.json.shipping_address.shipping_results.length > 0 && both_categories == true) {
23
        if (FC.json.context == "checkout") {
24
            $(".fc-checkout__section--shipping-results").append('<div class="row shipping-note"><div class="col-sm-10 col-sm-push-1">' + message + '</div></div>');
25
        } else {
26
            $(".fc-shipping-rates").append('<div class="fc-input-group--sidebar shipping-note"><br>' + message + '</div>');
27
        }
28
    }
29
});
30
</script>
31
{% endif %}