Skip to content

Bundled Discount RealOnePageCheckout Compatibility

Make Bundled discount compatible with RealOnePageCheckout plugin(nopTemplate).

To make Bundled discount plugin compatible with RealOnePageCheckout Plugin of nopTemplate you need to follow few steps as below:

Step:1

Add id="sub-total" In

SevenSpikes.Nop.Plugins.RealOnePageCheckout\Views\RealOnePageCheckout\OrderTotals.cshtml

Go to first row section of table as shown in below image:

Test

Step:2 Add id="real-onepage-total" In SevenSpikes.Nop.Plugins.RealOnePageCheckout\Views\RealOnePageCheckout\OrderTotals.cshtml

Go to section as shown in below image:

Test

Step:3

Go to SevenSpikes.Nop.Plugins.RealOnePageCheckout\Views\RealOnePageCheckout\OrderTotals.cshtml and add following script in end of the page.

<script>

    //ajax-call on SubTotal value change
    var orderSubTotal = document.getElementById('sub-total');
    var UpdateOrderSummary = {
        Url: '@Url.Action("UpdateRealOnePageCheckoutOrderSummary", "BundledDiscounts")'
    }
    orderSubTotal.addEventListener('DOMSubtreeModified', UpdateOrderSection);

    function UpdateOrderSection(e) {
        $.ajax({
            url: UpdateOrderSummary.Url,
            type: "POST",
            success: function (result) {
                if (result.Success) {

                    if (result.BundledDiscount == "") {
                        $('.order-bundle-discount').hide();
                    }
                    else {

                        if (!$(".cart-total tbody tr:first").hasClass('sub-total-row')) {
                            $(".cart-total tbody tr:first").addClass('sub-total-row');
                        }

                        var bundleHtml = "<tr class='order-bundle-discount'><td class='cart-total-left'>@T(\"Nop.Plugin.XcellenceIt.BundledDiscounts.Totals.BundleDiscount\"):</label >"
                            + "</td><td class='cart-total-right'>"
                            + "<span id='bundled-discount-amount' class='value-summary'>-" + result.BundledDiscount + "</span>"
                            + "</td></tr>";

                        $(".order-bundle-discount").remove();
                        $('.sub-total-row').after(bundleHtml);
                        $('.order-bundle-discount').show();
                    }

                    if ($('#real-onepage-total') != null) {
                        $('#real-onepage-total').html(result.OrderTotal);
                    }
                }
            }
        });
    }

</script>