Post by ssjal » Sat Nov 19, 2011 1:09 pm

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.

Attachments

group.jpg

group.jpg (15.02 KiB) Viewed 2862 times


New member

Posts

Joined
Thu Sep 17, 2009 4:45 pm

Post by ssjal » Sat Nov 19, 2011 9:56 pm

any solutions for this?

New member

Posts

Joined
Thu Sep 17, 2009 4:45 pm

Post by Q8Falcon » Thu Nov 24, 2011 11:11 pm

Hi ..

I think you can edit the cart template or the cart controller so the option wont be in more than line ..

Newbie

Posts

Joined
Thu Oct 13, 2011 8:36 pm

Post by ssjal » Wed Dec 28, 2011 11:26 pm

hi,
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>
but i can't figure out how can i have different option values under single option name

Thanks

New member

Posts

Joined
Thu Sep 17, 2009 4:45 pm

Post by Qphoria » Thu Dec 29, 2011 1:13 am

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>

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by straightlight » Thu Dec 29, 2011 1:17 am

ssjal wrote:hi,
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>
but i can't figure out how can i have different option values under single option name

Thanks
A quick example to this would be to regroup all your option names and values within an array as such:

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 } ?>
This should work as intented.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by ssjal » Fri May 04, 2012 10:35 pm

thanks straightlight for the code suggestion for values grouping.
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 } ?>
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.

Attachments

pizza1.jpg

pizza1.jpg (62.46 KiB) Viewed 2608 times


New member

Posts

Joined
Thu Sep 17, 2009 4:45 pm

Post by straightlight » Fri May 04, 2012 10:40 pm

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


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by ssjal » Fri May 04, 2012 10:59 pm

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.

New member

Posts

Joined
Thu Sep 17, 2009 4:45 pm

Post by straightlight » Fri May 04, 2012 11:03 pm

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


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON
Who is online

Users browsing this forum: No registered users and 44 guests