hometown Posted May 7, 2008 Share Posted May 7, 2008 Let me start off by saying that I know nothing about PHP, but I need a work around in order to make my open source e-commerce software do what I need it to do. The software allows for several products to be grouped and displayed on one page. These grouped products are displayed as follows on the front end: Product One Price Qty. Product Two Price Qty. Product Three Price Qty. Product Four Price Qty. For reasons I won't bore you with right now, I need to be able to display products like this: Product One Price Qty Product Two Price Qty Product Three Price Qty Product Four Price Qty After educating myself a little on PHP, I found out I could get rid of the table html so that all of the products appear in one row. I've tried that and it seems to work just fine. I think I should then be able to use the “Modulas %” operator to add a <br> after every other product as the code loops through. This is where I'm lost though. I have no idea on how to add this to the code. I've copied the section of code that displays the products on the front end for your reference. The parts that I think are most relevant I've highlighted in blue. Any direction or input will be greatly appreciated. Thanks <?php $_product = $this->getProduct() ?> <?php $_associatedProducts = $this->getAssociatedProducts() ?> <table cellspacing="0" class="data-table" id="super-product-table"> <tbody> <?php if (count($_associatedProducts)): ?> <?php foreach ($_associatedProducts as $_item): ?> <tr> <td><?php echo $this->htmlEscape($_item->getName()) ?></td> <td class="a-right"> <?php $_price = $_item->getPrice() ?> <?php $_finalPrice = $_item->getFinalPrice() ?> <?php if ($_finalPrice == $_price): ?> <span class="nobr"><?php echo Mage::helper('core')->currency($_price) ?></span><br /> <?php else: ?> <span class="nobr old-price"><?php echo $this->__('Price') ?> <?php echo Mage::helper('core')->currency($_price) ?></span><br /> <span class="nobr special-price” style="font-size:12px;"><?php echo $this->__('Special Price') ?> <?php echo Mage::helper('core')->currency($_finalPrice) ?></span> <?php endif; ?> <?php if($_item->getTierPriceCount()): ?> <?php foreach ($_item->getFormatedTierPrice() as $_tierPrice): ?> <?php if($_tierPrice['price'] <= $_finalPrice): ?> <span class="nobr"><?php echo $this->__('Buy %s for %s', $_tierPrice['price_qty']*1, $_tierPrice['formated_price']) ?></span> <?php endif; ?> <?php endforeach; ?> <?php endif; ?> </td> <?php if ($_product->isSaleable()): ?> <td class="a-center"> <?php if ($_item->isSaleable()) : ?> <input name="super_group[<?php echo $_item->getId() ?>]” value="<?php echo $_item->getQty()*1 ?>” type="text" class="input-text qty"/> <?php else: ?> <?php echo $this->__('Out of stock.') ?> <?php endif; ?> </td> <?php endif; ?> </tr> <?php endforeach; ?> <?php else: ?> <tr> <td colspan="<?php if ($_product->isSaleable()): ?>4<?php else : ?>3<?php endif; ?>"><?php echo $this->__('No options of this product are available.') ?></td> </tr> <?php endif; ?> </tbody> </table> Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted May 7, 2008 Share Posted May 7, 2008 There's a very good FAQ/post here on just this very thing. You are correct that the best approach to use is to use the modulus operator to work out when to create your new rows. Your code is quite hard to read. Not sure you're opening and closing PHP with every line; it's certainly not necessary! Quote Link to comment Share on other sites More sharing options...
Barand Posted May 7, 2008 Share Posted May 7, 2008 Your code is quite hard to read. Master of understatement. I took one look and moved on. Quote Link to comment Share on other sites More sharing options...
hometown Posted May 8, 2008 Author Share Posted May 8, 2008 Thank you Ben, I will take a look at the FAQ/post and see if I can make sense of it. As for the code I apologize, but the code is not mine, it is part of the open source software. Thanks again, Burton Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.