using opencart_v1.5.1.1
Under shopping cart details , can we group the product option values so that all option values selected by user come under a single heading instead of repeating headings each time to display the values.
Thanks.
Under shopping cart details , can we group the product option values so that all option values selected by user come under a single heading instead of repeating headings each time to display the values.
Thanks.
Attachments
group.jpg (15.02 KiB) Viewed 2862 times
hi,
The following code (checkout > cart.tpl) prints the product options
but i can't figure out how can i have different option values under single option name
Thanks
The following code (checkout > cart.tpl) prints the product options
Code: Select all
<div>
<?php foreach ($product['option'] as $option) { ?>
- <small><?php echo $option['name']; ?>: <?php echo $option['value']; ?></small><br />
<?php } ?>
</div>
Thanks
Replace with this:
Code: Select all
<?php $strOptVal = ''; ?>
<?php foreach ($product['option'] as $option) { ?>
<?php $strOpt = $option['name']; ?>
<?php $strOptVal .= $option['value'] . ',' ?>
<?php } ?>
<?php $str = ($strOpt . ': ' . trim($strOptVal, ',')); ?>
<div>
- <small><?php echo $str; ?></small><br />
</div>
A quick example to this would be to regroup all your option names and values within an array as such:ssjal wrote:hi,
The following code (checkout > cart.tpl) prints the product optionsbut i can't figure out how can i have different option values under single option nameCode: Select all
<div> <?php foreach ($product['option'] as $option) { ?> - <small><?php echo $option['name']; ?>: <?php echo $option['value']; ?></small><br /> <?php } ?> </div>
Thanks
Code: Select all
<?php $option_groups = array(); ?>
<?php foreach ($product['option'] as $option) { ?>
<?php $option_groups[$option['name']][] = array('value' => $option['value']); ?>
<?php } ?>
<?php if (!empty($option_groups) && !isset($option_group_name) && !isset($option_group_values)) { ?>
<?php foreach ($option_groups as $option_group_name => $option_group_values) { ?>
<div>
<?php echo $option_group_name; ?>
<?php if (is_array($option_group_values) && !isset($option_values)) { ?>
<?php foreach ($option_group_values as $option_values) { ?>
<div><small><?php echo $option_values['value']; ?></small><br /></div>
<?php } ?>
<?php } ?>
</div>
<?php } ?>
<?php } ?>
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
thanks straightlight for the code suggestion for values grouping.
Following is the code(checkout > cart.tpl):
i am using v1.5.1.1 for pizza shop where under a single product i have multiple products
eg: 2 MEDIUM PIZZAS, 3 TOPPINGS EACH, 12 CHICKEN WINGS, GARLIC BREAD & 2 POP for $25.99
the above contains 2 pizza, 12 wings, bread and pop.
due to many topping options the cart content and bill display becomes too long information sometime 2-3 pages printout for the bill.
can anyone guide me in clubing the options for each product in the code displayed above so that the product information is compacted and easier to read.
Following is the code(checkout > cart.tpl):
Code: Select all
<?php $option_groups = array(); ?>
<?php foreach ($product['option'] as $option) { if(($option['value']!='No') && ($option['value']!='Regular')){ ?>
<?php $option_groups[$option['name']][] = array('value' => $option['value']); ?>
<?php } } ?>
<?php if (!empty($option_groups)) { ?>
<?php foreach ($option_groups as $option_group_name => $option_group_values) { ?>
<div><small style="color:#8A0500;">
<?php echo $option_group_name.":"; ?></small>
<?php if (is_array($option_group_values)) { ?>
<?php foreach ($option_group_values as $option_values) { ?>
<small><?php echo $option_values['value'].","; ?></small>
<?php } ?>
<?php } ?>
</div>
<?php } ?>
<?php } ?>
eg: 2 MEDIUM PIZZAS, 3 TOPPINGS EACH, 12 CHICKEN WINGS, GARLIC BREAD & 2 POP for $25.99
the above contains 2 pizza, 12 wings, bread and pop.
due to many topping options the cart content and bill display becomes too long information sometime 2-3 pages printout for the bill.
can anyone guide me in clubing the options for each product in the code displayed above so that the product information is compacted and easier to read.
Attachments
pizza1.jpg (62.46 KiB) Viewed 2608 times
In your case of pizza, you'd need to use the related products. Once related, you can already display all the product names amongst each options as the demonstrated screenshot above.
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
thanks straightlight for your reply.
in case of pizza website, related products may not be a solution
Eg: 2 MEDIUM PIZZAS, 3 TOPPINGS EACH, 12 CHICKEN WINGS, GARLIC BREAD & 2 POP is a single product added to cart at one click. the customer has to select all the option for pizza, wings, bread pop where as in related products, he will have to add to cart each product and miss some also.
can u suggest alterations in the above code(checkout > cart.tpl) which can group values starting from specific wording.
Eg: product values under name 'Pizza 1' can be grouped under 1 head, values under 'Pizza 2' can be grouped under 1 head, values under chicken wings can be grouped under 1 head and so on.
some matching query syntax which fetches first 2 words from the each option name(eg: 'Pizza 1' from 'Pizza 1 - Veggie Toppings:'), matches its values with other and return selected values having same option name.
i shall be very thankful to you.
in case of pizza website, related products may not be a solution
Eg: 2 MEDIUM PIZZAS, 3 TOPPINGS EACH, 12 CHICKEN WINGS, GARLIC BREAD & 2 POP is a single product added to cart at one click. the customer has to select all the option for pizza, wings, bread pop where as in related products, he will have to add to cart each product and miss some also.
can u suggest alterations in the above code(checkout > cart.tpl) which can group values starting from specific wording.
Eg: product values under name 'Pizza 1' can be grouped under 1 head, values under 'Pizza 2' can be grouped under 1 head, values under chicken wings can be grouped under 1 head and so on.
some matching query syntax which fetches first 2 words from the each option name(eg: 'Pizza 1' from 'Pizza 1 - Veggie Toppings:'), matches its values with other and return selected values having same option name.
i shall be very thankful to you.
What you seem to be looking for is buying 'grouped products' and not grouped options. Grouped options are only represented amongst a single product anyhow normally while the grouped products may have multiple items into the same page which seem to be more what you're after. OpenCart currently does not have this functionality. Besides, the payment gateway / offline payment processing only allows 1 item per row (model / sku / ID, for instance) and not multiple values at the time during the transaction.
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Who is online
Users browsing this forum: No registered users and 44 guests