I am using the CakePHP Cart Plugin to add shop functionality to a website. I want to add items to the shopping cart using an AJAXified button. Submitting the form works fine. I am having trouble to correctly return just the shopped item as JSON data in method captureBuy() on line 210.
Which settings do I need to use and where/how do I set them? Any hint appreciated!
This is the request which is being sent:
Request URL:http://shop.site/carts_items/buy
Request Method:POST
Status Code:302 Found
Request Headers
Accept:application/json, text/javascript, */*; q=0.01
Accept-Encoding:gzip,deflate,sdch
Accept-Language:de-DE,de;q=0.8,en-US;q=0.6,en;q=0.4
Connection:keep-alive
Content-Length:134
Content-Type:application/x-www-form-urlencoded; charset=UTF-8
Cookie:CAKEPHP=cd4611d0bf0100247928990a8efa72d0; rememberMe[User]=2....BmKdEs;
DNT:1
Host:shop.site
Origin:http://shop.site
Referer:http://shop.site/offer/1
User-Agent:Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1553.0 Safari/537.36 SUSE/30.0.1553.0
X-Requested-With:XMLHttpRequest
Form Data
_method:POST
data[CartsItem][foreign_key]:72
data[CartsItem][model]:Product
data[CartsItem][quantity]:1
Response Headers
Connection:keep-alive
Content-Type:text/html; charset=UTF-8
Date:Mon, 23 Sep 2013 20:32:28 GMT
Location:http://shop.site/offer/1
Server:nginx/1.0.15
Transfer-Encoding:chunked
Define "not correctly". Paste your request and response from your network tab (in Chrome).
You don't have to set the items, the CartManager is already setting them to the view and serializes them. At least it should.
Make sure you have the RequestHandler component loaded as well.