Jump to content

J2Store - Joomla - Array


djforema

Recommended Posts

I'm using the J2Store add-on for Joomla.  The store prints out a invoice and I am editing what prints out.  Right now it prints out each item ordered and the 'options' with that item.  (Ex. You can order a Large shirt the options are its a t-shirt and blue.) 

 

What I'm trying to do is make a list of all the material ('options') and quanities in each order.

 

Below is the section of code I have been working with.  I added '<?php echo count($item); ?>' to the code but it just lists the 'options' then a 1 after, but only for one item in the order.

 

The J2Store support told me this:

"

first you need to decode the $item->orderitem_attributes
Then you need to parse through the array and get the options in a required format by sorting and using multiple loops.

Then count each option. Example count($array['large']);

"

    <?php if(!J2StoreOrdersHelper::isJSON(stripslashes($item->orderitem_attribute_names))): ?>

                            <?php if (!empty($item->orderitem_attribute_names)) : ?>
                                <span><?php echo $item->orderitem_attribute_names; ?></span>
                            <?php endif; ?>
                        <br />
                        <?php else: ?>
                        <!-- since 3.1.0. Parse attributes that are saved in JSON format -->
                        <?php if (!empty($item->orderitem_attribute_names)) : ?>
                            <?php
                                //first convert from JSON to array
                                $registry = new JRegistry;
                                $registry->loadString(stripslashes($item->orderitem_attribute_names), 'JSON');
                                $product_options = $registry->toObject();
                            ?>
                                <?php foreach ($product_options as $option) : ?>
                                - <small>
                                    <?php echo JText::_($option->name); ?>: <?php echo JText::_($option->value); ?>
                                        
                                        <?php echo count($item); ?>

                                    <?php if(isset($option->option_sku) && JString::strlen($option->option_sku) > 0):?>
                                        (<?php echo JText::_('J2STORE_SKU'); ?> : <?php echo $option->option_sku; ?>)
                                    <?php endif; ?>
                                </small><br />
                               <?php endforeach; ?>
                            <br/>
                        <?php endif; ?>
                    <?php endif; ?>
Edited by Zane
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

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

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.