Jump to content

adding extra field review


Recommended Posts

im a bit struggling to get something working 

want to add an extra field in the review page

so in content.product.php i add

				<label for="rev_bijkomend">bijkomende opmerking</label>
				<input id="rev_bijkomend" type="text" name="bijkomend" value="{$WRITE.bijkomend}" class="textbox" />

in cubecart.class.php after 

  $record['rating']   = (isset($_POST['rating'])) ? $_POST['rating'] : 0;
            $record['product_id']  = (int)$_GET['product_id'];
            $record['ip_address']  = get_ip_address();
            $record['time']    = time();

i add 

$record['bijkomend']   = (isset($_POST['bijkomend']));

in database i added the new table bijkomend set as text 


  but whatever i do , it doesn't store the field bijkomend in the database. 
What am i doing wrong ?           


Link to comment
Share on other sites

Let's review:

$record['bijkomend']   = (isset($_POST['bijkomend']));

The form element with the input name "bijkomend" will get POSTed if the input tag is within the appropriate <form> block.

The statement above tests if the form element exists in the POSTed data. But, so far, the answer is either a 'true' or a 'false' logical value.

This is the start of a typical test structure called a Tertiary Operator. We can see that with the $_POST['rating'].

To finish that statement:

$record['bijkomend']   = (isset($_POST['bijkomend'])) ? $_POST['bijkomend'] : '';

The $record array will be saved in the CubeCart_reviews database table, so the new column 'bijkomend' should have been added to that table.

  • Thanks 1
Link to comment
Share on other sites

thank you , that works. 

still learning 🙃

i tried a lot of things. 

and something i really dont understand...
when you look at the form to submit the review , you have the title and review box

but it you look at the functions to add it in the database , nothing there to find for those boxes. 

Link to comment
Share on other sites

CubeCart takes a shortcut.

Let's look at the private function _product() in the cubecart.class.php file. About twelve lines in, the entirety of the $_POST['review'] array is passed to $record (after encoding all the special characters). The $_POST['review'] array includes: 'anon' or 'name' and 'email', 'title', 'review'.

Now, $record has those array elements.

The code that actually does the database insertion checks to make sure that there is a table column having the same name as the array element key. Thus, the value in $record['title'] will end up in the 'title' column of the row being inserted.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...