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.

Custom shipping does not work on 2.0

AcalexAcalex Member
in Help edited September 2014
Hello,

On the previous version of the shop I had setup different type of shipping according to the CAP of the city in Belgium.
Now it doesn't work anymore, any hint on where to restart to setup that again?

Thanks a lot
«1
Comments
  • There are a couple of other discussions on this. Info will appear on https://wiki.foxycart.com/v/2.0/snippets when it's available, latest news is that it'll be this week.
  • fc_adamfc_adam FoxyCart Team
    @Acalex,

    Yeah - there will be updated shipping snippets for 2.0, as with the completely rebuild javascript existing 1.1 snippets won't work.
  • Thanks @fc_adam,

    so I need to hold on until the new one is available. Will the code be the same I produced before or I will need to remake it all over?

    Thanks
  • fc_adamfc_adam FoxyCart Team
    @Acalex,

    Yeah - you won't be able to have custom shipping until the new logic is complete. The custom shipping logic will change in some instances - as the variables within and the way you access the JSON is different.
  • fc_adamfc_adam FoxyCart Team
    @Acalex, @Up,

    The new snippet for flat rates is now available at https://wiki.foxycart.com/v/2.0/snippets/flat_rate_shipping_modification - thanks for your patience
  • Thanks a lot.
    This was my logic with different shipping rate depending on postal code, but it doesn't work! :(
    Any suggestion on where to start modifying?

    Thanks a lot

    if (typeof(postal_code) === "undefined") {postal_code= "";}
    if (typeof(country_code) === "undefined") {country_code = "";}
    new_country_code = (jQuery("#use_different_addresses").is(":checked") ? $("#shipping_country").val() : $("#customer_country").val());
    new_postal_code = (jQuery("#use_different_addresses").is(":checked") ? $("#shipping_potstal_code").val() : $("#customer_postal_code").val());
    if (country_code != new_country_code || postal_code != new_postal_code) { // The shipping country has changed!
    country_code = new_country_code;
    postal_code = new_postal_code;
    removeCustomShippingContainer(); // This call will make sure that when it updates, it starts fresh.

    if (country_code == "BE") {

    if (postal_code >= 1000 && postal_code <= 1210) {
    postage = 10;
    addShippingOption(1, 0, 'Local pick-up Brussels (Etterbeek)');
    addShippingOption(2, postage, 'Brussels delivery (FREE > 60€)');

    if (fc_json.total_item_price > 60) {
    updateShippingOptionCost(2, 0); }

    } else if (postal_code >= 1300 && postal_code <= 1999) {
    postage = 20;
    addShippingOption(1, 0, 'Local pick-up Brussels (Etterbeek)');
    addShippingOption(3, postage, 'Brabant provinces (FREE > 150€)');

    if (fc_json.total_item_price > 150) {
    updateShippingOptionCost(3, 0); }

    } else if (postal_code >= 2000) {
    postage = 30;
    addShippingOption(1, 0, 'Local pick-up Brussels (Etterbeek)');
    addShippingOption(4, postage, 'Other provinces (FREE > 250€)');

    if (fc_json.total_item_price > 250) {
    updateShippingOptionCost(4, 0); }
    }

    }
    }


  • fc_adamfc_adam FoxyCart Team
    @Acalex,

    Give this a try:
    var country_code = address.country;
    var postal_code = address.postal_code;
    
    if (country_code == "BE") {
      if (postal_code >= 1000 && postal_code <= 1210) {
        postage = 10;
        FC.customFlatRates.add(1, 0, 'Local pick-up Brussels (Etterbeek)');
        FC.customFlatRates.add(2, postage, 'Brussels delivery (FREE > 60€)');
    
        if (FC.json.total_item_price > 60) {
          FC.customFlatRates.update(2, 0); 
        }
      } else if (postal_code >= 1300 && postal_code <= 1999) {
        postage = 20;
        FC.customFlatRates.add(1, 0, 'Local pick-up Brussels (Etterbeek)');
        FC.customFlatRates.add(3, postage, 'Brabant provinces (FREE > 150€)');
    
        if (FC.json.total_item_price > 150) {
          FC.customFlatRates.update(3, 0); 
        }
      } else if (postal_code >= 2000) {
        postage = 30;
        FC.customFlatRates.add(1, 0, 'Local pick-up Brussels (Etterbeek)');
        FC.customFlatRates.add(4, postage, 'Other provinces (FREE > 250€)');
    
        if (FC.json.total_item_price > 250) {
          FC.customFlatRates.update(4, 0); 
        }
      }
    }
    
  • Wonderful @fc_adam, thanks a lot.

    I still have only one issue. Didn't understand well where I have to past the code injection as explained in the wiki. I have to do in Foxy cart admin panel or on Squarespace (considering my website is on Sqaurespace).

    If it's squarespace, is it here basically?

    Squarespace---Configuration.png
  • fc_adamfc_adam FoxyCart Team
    @Acalex,

    Huh - looks like squarespace has similar language there! It's within your FoxyCart administration that you'll want to add it. I'll add some clarification to the wiki to make that clearer.
  • Yes, thats why I got confused!
  • chesterpchesterp Member
    edited December 2014
    @fc_adam,

    Im trying to use a custom shipping fee on a total price, Im not sure if Im doign it right,
    to test I tried to put some code on FC.customFlatRates.logic liek below
        FC.customFlatRates.logic = function() {
        /* BEGIN CUSTOM SHIPPING LOGIC */
    // Will create a condition here fo rtotal price, for testing I put the code below
    FC.customFlatRates.add(1, 0, '','Standard');
    FC.customFlatRates.update(1, 100); 
    
    
        /* END CUSTOM SHIPPING LOGIC */
        };
    

    that function doesnt run without calling it, I called it at the end of the sample scripts on foxycart site like
    })(FC, jQuery);
    FC.customFlatRates.logic();
    

    When I reload the checkout page, the shipping fee is set to TBD.

    Im not sure, if Im doing it right, scenario is if total order is greater than 100 set different shipping fee

    Thanks
  • brettbrett FoxyCart Team
    @chesterp, can you whisper me your store domain?
  • brettbrett FoxyCart Team
    Hey @chesterp, could you put the code in place so I can see what you have? If it's breaking things, put it in but commented out. Or put it in a pastie.org. That way we can test things out.
  • brettbrett FoxyCart Team
    @chesterp, what you want is probably something like this:
    FC.customFlatRates.add(1, 9, 'Standard');
    if (FC.json.total_item_price >= 100) {
      FC.customFlatRates.update(1, 0); 
    }
    
    Does that help?
  • Hey @fc_adam still confused on this. Could you please provide some help to fix the shipping logic? Is the only thing which is keeping me from activating my subscription :(

    Thanks
  • Do I need to copy the code you pasted in the Checkout template of my Foxycart store?
    But I have now the Responsive template activated. Shall I switch to custom template and paste the code?
  • fc_adamfc_adam FoxyCart Team
    @Acalex,

    Sure thing. You don't need to edit the checkout template direct, you can simply paste it into the "footer" section of the "add custom code to the header and footer" configuration option in the template configuration of your store's FoxyCart administration.
  • Done that @fc_adam but still not working :(
  • I have copied this code

    var country_code = address.country;
    var postal_code = address.postal_code;

    if (country_code == "BE") {
    if (postal_code >= 1000 && postal_code <= 1210) {
    postage = 10;
    FC.customFlatRates.add(1, 0, 'Local pick-up Brussels (Etterbeek)');
    FC.customFlatRates.add(2, postage, 'Brussels delivery (FREE > 60€)');

    if (FC.json.total_item_price > 60) {
    FC.customFlatRates.update(2, 0);
    }
    } else if (postal_code >= 1300 && postal_code <= 1999) {
    postage = 20;
    FC.customFlatRates.add(1, 0, 'Local pick-up Brussels (Etterbeek)');
    FC.customFlatRates.add(3, postage, 'Brabant provinces (FREE > 150€)');

    if (FC.json.total_item_price > 150) {
    FC.customFlatRates.update(3, 0);
    }
    } else if (postal_code >= 2000) {
    postage = 30;
    FC.customFlatRates.add(1, 0, 'Local pick-up Brussels (Etterbeek)');
    FC.customFlatRates.add(4, postage, 'Other provinces (FREE > 250€)');

    if (FC.json.total_item_price > 250) {
    FC.customFlatRates.update(4, 0);
    }
    }
    }
  • fc_adamfc_adam FoxyCart Team
    @Acalex,

    Sorry for not being clearer there - that code is only part of the snippet. You need to read through the instructions on this page: https://wiki.foxycart.com/v/2.0/snippets/flat_rate_shipping_modification - and when it calls for the custom logic, use what you posted above.
  • Hello @fc_adam, right. I have done that but still nothing moves. When I type de postal code in the checkout page nothing happens and everything remains at 0,00. Still do not know whats wrong :(
  • fc_adamfc_adam FoxyCart Team
    @Acalex,

    Is this for the Olivetus store? I just tried entering the postcode 1210 for Belgium and it's setting the custom rates just fine.
  • Yes it's for the Olivetus store. Seriously? I have tried now also and still no luck. Might be the Safari browser?
    Just to make sure, you click on Proceed to checkout and in the checkout page you enter your data, correct @fc_adam?

    Thanks
  • No luck with Chrome either :(. I also tried to deactivate the automatic look-up of cities based on postal code but didn't work. I removed the tick on the option but the system still automatically does that. Not sure if that might be the reason
  • Here it is my screenshot: http://screencast.com/t/8mVrzGtiH8
    Tried to change the CAP to 5000 but I still get 0,00€ on Shipping & Handling on the right
  • fc_adamfc_adam FoxyCart Team
    @Acalex,

    Ah I see the confusion. You're looking at a different store - but it's hard to tell as both of your Olivetus stores have the same store name, but different store domains. The store you've applied the shipping to is the store that you've applied the logo to.
  • Hi @fc_adam, didn't get it. The domain is different? Could you please explain a bit better?

    Thanks a lot
  • fc_adamfc_adam FoxyCart Team
    @Acalex,

    You have two FoxyCart stores attached to your user account - both with the same store name. That means that within the dropdown, you can't which store is which.

    When I said the store domains are different, I meant that although both of the stores share the same name, they do have a unique store domain (as in storea.foxycart.com and storeb.foxycart.com). The FoxyCart store you applied the custom shipping snippet to is different than the one you're testing it on. If you test with your other store, you should see it working then.
  • @fc_adam, thanks for the answer but I have no idea I had 2 stores, seriously. How is that possible? What shall I do to remove one of the stores?
  • Found it! Thanks a lot!

    Now, just one thing, why do I always get the word "undefined" when I select a shipping method? Look at the attachment for more explanation. Below "Other provinces"

    http://screencast.com/t/gwKIBKpRXbRc
Sign In or Register to comment.