Customising Checkout View ... strange problem

  • Posts: 139
  • Thank you received: 1
11 years 1 month ago #129803

Via the display menu I have edited checkout / cart.php so that it displays four of my custom fields.

The following code has been inserted into the "<div class="hikashop_cart_product_custom_item_fields">" section as PHP

echo '<p><strong>Date:</strong> '.$this->row->date.'<br/>';
echo '<strong>No. of Days:</strong> '.$this->row->noofdays.'<br/>';
echo '<strong>Age Group:</strong> '.$this->row->agegroup.'<br/>';
echo '<strong>Prerequisites:</strong> '.$this->row->prer
equisites.'</p>';
[/code]

This works for all but the 1st item in the cart (see image below).



As you can see the entries for the custom fields are blank, even though they do have data. This happens to whatever product is listed first.

Any ideas on how I can fix this?

Since posting this I have just upgraded to "Business" so there may be a better way to do this.

Attachments:
Last edit: 11 years 1 month ago by abasel.

Please Log in or Create an account to join the conversation.

  • Posts: 12953
  • Thank you received: 1778
11 years 1 month ago #129818

Hi,
Can you try it with this code :

foreach($this->rows as $row){
echo '<p><strong>Date:</strong> '.$row->date.'<br/>';
echo '<strong>No. of Days:</strong> '.$row->noofdays.'<br/>';
echo '<strong>Age Group:</strong> '.$row->agegroup.'<br/>';
echo '<strong>Prerequisites:</strong> '.$row->prer;
}
You'll have to put it just after these lines :
                <div class="hikashop_cart_product_custom_item_fields">
                <?php

Please Log in or Create an account to join the conversation.

  • Posts: 139
  • Thank you received: 1
11 years 1 month ago #129918

Hi, this simply repeats the fields by the number of rows, with the first entries still being blank.

Attachments:

Please Log in or Create an account to join the conversation.

  • Posts: 82906
  • Thank you received: 13378
  • MODERATOR
11 years 4 weeks ago #129982

No what mohamed provided is not correct.

What you just need to do is to use

echo '<p><strong>Date:</strong> '.$row->date.'<br/>';
echo '<strong>No. of Days:</strong> '.$row->noofdays.'<br/>';
echo '<strong>Age Group:</strong> '.$row->agegroup.'<br/>';
echo '<strong>Prerequisites:</strong> '.$row->prerequisites.'</p>';
instead of the code that you posted first:
echo '<p><strong>Date:</strong> '.$this->row->date.'<br/>';
echo '<strong>No. of Days:</strong> '.$this->row->noofdays.'<br/>';
echo '<strong>Age Group:</strong> '.$this->row->agegroup.'<br/>';
echo '<strong>Prerequisites:</strong> '.$this->row->prerequisites.'</p>';
That's because $this->row doesn't existing at the beginning of the foreach, only at the end, so each time you're actually displaying the data of the previous product with your code instead of displaying the data of the current product, and that's why the first one has empty values with your code.

The following user(s) said Thank You: abasel, Mohamed Thelji

Please Log in or Create an account to join the conversation.

  • Posts: 139
  • Thank you received: 1
11 years 4 weeks ago #129988

Awesome, that worked.. thanks :cheer:

Please Log in or Create an account to join the conversation.

Time to create page: 0.078 seconds
Powered by Kunena Forum