The Foxy forums are on the move!

We're in the process of moving our forums over to a new system, and so these forums are now read-only.
If you have a question about your store in the meantime, please don't hesitate to reach out to us via email.

Javascript Events - Sidecart Show


We've followed the guidance here:

We simply we want to execute some custom JQuery when the side cart is shown... we've added the following to an external JS file (not within document ready).

var FC = FC || {};
FC.onLoad = function () {
FC.client.on("sidecart-show", function (params, next) {
alert("Show side cart");

The alert is fired but then the side cart doesn't load... what are we doing wrong?

We did also try:

FC.client.on("render.done", function (params) {
alert("render done");

But this is fired three to four times...

Any ideas?

  • fc_adamfc_adam FoxyCart Team
    edited October 2018

    You're really close there. Your first approach is how you'd want to do it, except without the "next" parameter. When that's included, it makes your callback function async, and so you have to call next(); for the event to continue.

    If you don't need it async, your code would just want to be this:
    var FC = FC || {};
    FC.onLoad = function () {
    FC.client.on("sidecart-show", function (params) {
    alert("Show side cart");
    If you wanted to only run after the sidecart has shown, you can do that by making the event sidecart-show.done too.
  • BLJBLJ Member
    Thanks Adam, brilliant!

    All sorted... we're running some logic to show / hide the paypal checkout icons based on whether the shipping options have been confirmed.

    FC.client.on("cart-shipping-options-update.done", function (params) {
    $shippingVal = $(".fc-transaction__shipping").find(".fc-subtotal__value").text().trim();
    if ($shippingVal != "TBD") { $(".fc-action--payment--or").show("slow");
Sign In or Register to comment.