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.

Multiship & other use of FC.onLoad

jingarijingari Member
I am having an issue with using multiship and being able to separate use FC.onLoad in order to access the Cart. Is there something basic that I am missing? I am using Foxy-shop, but the multiship code is like the one here: https://wiki.foxycart.com/integration/foxycart/multiship_javascript_2

And then I also have another script that looks like this:
var FC = FC || {};
FC.onLoad = function () {
FC.client.on("ready.done", function(params){
//debugging
console.log("FCjson"+FC.json);
console.log('count'+FC.json.item_count);
//end debugging

if(FC.json.item_count >0){
if(!$("#fc_minicart").hasClass("isFull")){
$("#fc_minicart").addClass("isFull");
}
if(!$("#fc_minicart_mobile").hasClass("full")){
$("#fc_minicart_mobile").addClass("full");
}
}
else{
$("#fc_minicart").removeClass("isFull");
$("#fc_minicart_mobile").removeClass("full");
}
})
.on("cart-update", function(params){
$(function (){
$('.fc-cart__item__option__name').each(function (){
console.log("fc-cart__item__option__name ="+$(this).html());
$(this).text("Card:");
});
});
console.log('cartItemChange'+FC.json.product_count);
if(FC.json.item_count >0){
if(!$("#fc_minicart").hasClass("isFull")){
$("#fc_minicart").addClass("isFull");
}
if(!$("#fc_minicart_mobile").hasClass("full")){
$("#fc_minicart_mobile").addClass("full");
}
}
else{
$("#fc_minicart").removeClass("isFull");
$("#fc_minicart_mobile").removeClass("full");
}
})
.on("cart-submit", function(params){
$( "select[name=Choose_your_card]" ).val("");
console.log("reset");
});

};


This script is loaded, but never gets into the FC.onLoad on my product pages where the multiship script also exists. If I comment out the
var FC = FC || {};
FC.onLoad = function () {
FC.client.on('cart-submit', setCookie);
FC.client.on('cart-submit.done', constructShipTo);
};

in the multiship script, then mine does work.
I assume one is overwriting the other, but I am not sure how to structure it so both the multiship.js and my other script can both access FC.

Thanks for any direction you can provide.
Comments
  • fc_adamfc_adam FoxyCart Team
    @jingari,

    Your assumption there is spot on - the FC.onload function is being overwritten. You'll need to simply combine them together, so add the following into your own onload function:
    FC.client.on('cart-submit', setCookie);
    FC.client.on('cart-submit.done', constructShipTo);
  • Ok, thank you!
Sign In or Register to comment.