bigcartel-themes / snakebite

Snakebite theme for Big Cartel.
https://help.bigcartel.com/themes/snakebite/
3 stars 1 forks source link

Previewing an empty cart page in the admin redirects back to the actual store #31

Closed mattwigham closed 10 years ago

coryetzkorn commented 10 years ago

This intentional, although I can see how it might be confusing if viewing through the admin interface.

mattwigham commented 10 years ago

Sorry, I mean it's redirecting back to your "actual" store, not the preview store. Meaning if you're using a completely different theme in your real store, previewing Snakebit's empty cart page will redirect you back to that other theme. It looks like this is because you're using ../ instead of /.

    setTimeout(function() {
      document.location.href = '../'; 
    }, 1500);

However, even updating the href will probably still cause problems in the admin, so you may need to do what a few of our themes do and check if it's in the preview area and don't redirect if so. Ex:

if(!(/\/admin\/design/.test(top.location.pathname))) {
    setTimeout(function() {
      document.location.href = '../'; 
    }, 1500);
}
mattwigham commented 10 years ago

For reference, typically the theme will set inPreview as a variable, and use that as needed to optimize things for the preview area. Ex: https://github.com/bigcartel-themes/luna/blob/master/source/javascripts/store.js#L8

coryetzkorn commented 10 years ago

Thanks for the detailed examples! This should be resolved.