Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting Spree Cart implemented in sub-domain Rails

Scenario

We have a rails application mounted with Spreecommerce as Rails::Engine and hosted at dashboard.domainname.com and available through dashboard.domainname.com/store then we have the wordpress for front-end implemented at www.domainname.com.

Requirement

We now need to show the checkout amount and quantity in the wordpress side of the application. Clicking on this would lead to checkout of the rails application itself so won't be problem for there on.

  • How do we achieve this?
  • Is it accessible through cookies?
  • If so how can it be shared throughout different sub-domains?

Spreecommerce checkout requirement

*Note: Please consider that a user can add products to cart even without signing in.

like image 832
sushil10018 Avatar asked Feb 12 '16 13:02

sushil10018


1 Answers

Use secure/encrypted cookies to share cart details with wordpress and rails,

How do we achieve this?

Use cookies, Storing an encrypted cookie with Rails, http://api.rubyonrails.org/classes/ActionDispatch/Session/CookieStore.html

Is it accessible through cookies?

Yes, refer above answer.

If so how can it be shared throughout different sub-domains?

cookies.signed[:secret] # returns "foo bar"

Tutorial, Here.

like image 86
Albert Paul Avatar answered Nov 10 '22 17:11

Albert Paul