Shopping Cart
This is an open discussion with 110 replies, filed under Extensions.
Search
Sorry I've not understood what you are asking me to do. Do you mean to add
var_dump($_REQUEST);die;
before the the __trigger function
?
This is what my code would like if my interpretation is correct.
public function load() { if(isset($_REQUEST['cart-action']) && !empty($_REQUEST['cart-action'])){ return $this->__trigger(); } } var_dump($_REQUEST);die; protected function __trigger() { $xml = new XMLelement('shopping-cart'); if($_GET['cart-action']){ $action = $_GET['cart-action']; } else { list($action) = array_keys($_POST['cart-action']); } if(!method_exists($this, $action)) { $this->_error = true; $this->_msg = __('Unaccepted action'); } if(!$this->_error) { $this->_s = &$_SESSION[__SYM_COOKIE_PREFIX_ . 'cart']; $this->$action(); } $xml->setAttributeArray(array('action' => General::sanitize($action), 'result' => $this->_error == true ? 'error' : 'success')); $xml->appendChild(new XMLElement('msg', $this->_msg)); return $xml; }
which would give me the following error
Parse error: syntax error, unexpected T_STRING, expecting T_FUNCTION in /Applications/XAMPP/xamppfiles/htdocs/amccandlish/extensions/shopping_cart/events/event.shopping_cart.php on line 92
public function load() { if(isset($_REQUEST['cart-action']) && !empty($_REQUEST['cart-action'])){ var_dump($_REQUEST);die; return $this->__trigger(); } }
This is what it's giving me where 283 is the id of the product.
array(4) { ["symphony-page"]=> string(30) "categories/category/christmas/" ["id"]=> string(3) "283" ["cart-action"]=> array(1) { ["add"]=> string(13) "Add to Basket" } ["PHPSESSID"]=> string(32) "a69e50d76184a8268561476503872cf8" }
Ok, interesting.
Take the var_dump
out and put inside the dataIsValid
function after this line: $this->_id = $_REQUEST['id'];
Let's see if it is getting to this part.
Should the code look like this?
$this->_id = $_REQUEST['id']; dataIsValid; if($idOnly) return true;
Sorry. I misunderstood what you've asked me to do. Here is the result after putting the var_dump inside the dataIsValid function
array(4) { ["symphony-page"]=> string(30) "categories/category/christmas/" ["id"]=> string(3) "283" ["cart-action"]=> array(1) { ["add"]=> string(13) "Add to Basket" } ["PHPSESSID"]=> string(32) "a69e50d76184a8268561476503872cf8" }
So we now know that the entry ID is being correctly passed in to functions. The SQL generated with this ID should return another ID for the table.
Can you remove the var_dump
now and under this line: $fieldID = Symphony::Database()->fetchVar('id', 0, $sql);
add `var_dump($fieldID);die;
The result is NULL
Does your section have a price
field i it? That's what the query is looking for
Yes it does.
I'm really sorry. I've noticed how silly I've been. I've created a text field called Price rather than include the special type field Price. It seems to work now. I'll check with the other functions, drop, update, calculate to see if they work as well.
Personally, I disagree with having the 'Price' field. It should not be hard coded to require the specific field-type.
It's an easy mistake to make dude, no worries.
Thank you for your time. I appreciate it a lot.
Can anyone confirm whether or not this extension works in 2.3?
This is on of the extensions I'd like to involve with the Symphonists (Community extension maintenance), just got to get to this one on the list.
I've forked and am going through the code to update it.
If you want to setup a symphonists repo for it I can send a pull request once it's there? your call.. happy to help either way... testing locally with 2.3 now.
Thanks for looking into this Andrew, but could you fork from Andrrr's original extension as there have been more commits since.
Also, to all those that have forks, can you do pull requests back to the original?
Ahh right, I'll switch fork. No worries!
Do we not want the weight field from mblabs fork then? Just checking?
Create an account or sign in to comment.
You're right, it's the product (entry) id that needs passing, my bad.
Can you
var_dump($_REQUEST);die;
just before the__trigger
function is called in theload
function ofevent.shopping_cart.php
, and see if theid
is in the output.