So,
I've been trying to make a template, which runs plugin functions.
Here is template I've tried to make.
And here are the errors I get
Warning: Invalid argument supplied for foreach() in C:\www\htdocs\FCN-GIT\wp-content\themes\Avada-Child-Theme\single-wpt_test.php on line 39
Fatal error: Call to undefined method WP::doAction() in C:\www\htdocs\FCN-GIT\wp-content\themes\Avada-Child-Theme\single-wpt_test.php on line 44
<?php
/**
* Template Name: Test
*
* #package WordPress
* #subpackage Avada
* #since 2016
*/
?>
<?php
// Can be overriden in your theme as entry-content-wpt-test-fill-form.php
/* #var $answerIdName string */
/* #var $answerIndex integer */
/* #var $isShowContent boolean */
/* #var $formAttributes array */
/* #var $content string */
/* #var $subTitle string */
/* #var $shortDescription string */
/* #var $test WpTesting_Model_Test */
/* #var $questions WpTesting_Model_Question[] */
/* #var $isFinal boolean */
/* #var $isMultipleAnswers boolean */
/* #var $submitButtonCaption string */
/* #var $stepsCounter string */
/* #var $wp WpTesting_WordPressFacade */
/* #var $hiddens array */
?>
<div class="wpt_test fill_form">
<?php if ($isShowContent): ?>
<div class="content">
<?php echo $content ?>
</div>
<?php endif ?>
<div class="content"><form
<?php foreach ($formAttributes as $key => $value):?>
<?php echo $key ?>="<?php echo htmlspecialchars(is_array($value) ? json_encode($value) : $value) ?>"
<?php endforeach ?>>
<?php if ($subTitle): ?><h2 class="subtitle"><?php echo $subTitle ?></h2><?php endif ?>
<?php if ($shortDescription): ?><div class="short-description"><?php echo $wp->autoParagraphise($shortDescription) ?></div><?php endif ?>
<?php $wp->doAction('wp_testing_template_fill_form_questions_before') ?>
<?php foreach($questions as $q => $question): /* #var $question WpTesting_Model_Question */ ?>
<?php $wp->doAction('wp_testing_template_fill_form_question_before', $question, $q) ?>
<div class="question">
<div class="title">
<span class="number"><?php echo $q+1 ?>.</span><span class="title"><?php echo $question->getTitle() ?>
<?php $wp->doAction('wp_testing_template_fill_form_label_end', array('required' => true)) ?></span>
<?php if (!$isMultipleAnswers): ?>
<input type="hidden" name="<?php echo $answerIdName ?>[<?php echo $answerIndex ?>]" value="" />
<?php endif ?>
</div>
<?php foreach($question->buildAnswers() as $a => $answer): /* #var $answer WpTesting_Model_Answer */ ?>
<?php $answerId = 'wpt-test-question-' . $question->getId() . '-answer-' . $answer->getId() ?>
<div class="answer">
<label for="<?php echo $answerId ?>">
<input type="<?php echo $isMultipleAnswers ? 'checkbox' : 'radio' ?>" id="<?php echo $answerId ?>"
data-errormessage="<?php echo $isMultipleAnswers
? __('Please select at least one answer.', 'wp-testing')
: __('Please choose only one answer.', 'wp-testing') ?>"
<?php if (0 == $a): ?>required="required" aria-required="true"<?php endif ?>
name="<?php echo $answerIdName ?>[<?php echo $answerIndex ?>]" value="<?php echo $answer->getId() ?>" />
<?php echo $answer->getTitleOnce() ?>
</label>
</div>
<?php if ($isMultipleAnswers) {$answerIndex++;} ?>
<?php endforeach ?>
</div>
<?php $wp->doAction('wp_testing_template_fill_form_question_after', $question, $q) ?>
<?php if (!$isMultipleAnswers) {$answerIndex++;} ?>
<?php endforeach ?>
<?php $wp->doAction('wp_testing_template_fill_form_questions_after') ?>
<?php if($isFinal): ?>
<p>
<input type="submit" class="button" value="<?php echo $submitButtonCaption ?>" />
<?php if($stepsCounter): ?><span class="steps-counter"><?php echo $stepsCounter ?></span><?php endif ?>
</p>
<?php else: ?>
<div class="wpt_warning">
<h4><?php echo __('Test is under construction', 'wp-testing') ?></h4>
<p><?php echo __('You can not get any results from it yet.', 'wp-testing') ?></p>
</div>
<?php endif ?>
<?php foreach($hiddens as $name => $value): ?><input type="hidden" name="<?php echo htmlspecialchars($name) ?>" value="<?php echo htmlspecialchars($value) ?>" /><?php endforeach ?>
</form></div>
</div>
I managed to fix this, but overriding the default template of the plugin, I needed to have two templates which differences in one, so essentially, a template which has code for my homepage and for another page.
The homepage has the changes, and the other page does not, and it uses the default theme template.
Here was my solution to having two templates in one using the plugin code.
<?php
// Can be overriden in your theme as entry-content-wpt-test-fill-form.php
/* #var $answerIdName string */
/* #var $answerIndex integer */
/* #var $isShowContent boolean */
/* #var $formAttributes array */
/* #var $content string */
/* #var $subTitle string */
/* #var $shortDescription string */
/* #var $test WpTesting_Model_Test */
/* #var $questions WpTesting_Model_Question[] */
/* #var $isFinal boolean */
/* #var $isMultipleAnswers boolean */
/* #var $submitButtonCaption string */
/* #var $stepsCounter string */
/* #var $wp WpTesting_WordPressFacade */
/* #var $hiddens array */
?>
<?php if (is_front_page()): ?>
<div class="home-health-insight wpt_test fill_form">
<div class="answers">
<div class="content">
<form
<?php foreach ($formAttributes as $key => $value):?>
<?php echo $key ?>="<?php echo htmlspecialchars(is_array($value) ? json_encode($value) : $value) ?>"
<?php endforeach; ?>>
<?php if ($isShowContent): ?><div class="content" style="margin:0;"><?php echo $content ?></div><?php endif ?>
<?php if ($shortDescription): ?><div class="short-description"><?php echo $wp->autoParagraphise($shortDescription) ?></div><?php endif ?>
<?php $wp->doAction('wp_testing_template_fill_form_questions_before') ?>
<div class="question">
<div class="question-titles">
<div class="question-labels">
<label class="answerlbl" for="<?php echo $answerId ?>">
None of the time
</label>
<label class="answerlbl" for="<?php echo $answerId ?>">
Rarely
</label>
<label class="answerlbl" for="<?php echo $answerId ?>">
Some of the time
</label>
<label class="answerlbl" for="<?php echo $answerId ?>">
Often
</label>
<label class="answerlbl" for="<?php echo $answerId ?>">
All of the time
</label>
</div>
</div>
<?php foreach($questions as $q => $question): /* #var $question WpTesting_Model_Question */ ?>
<?php $wp->doAction('wp_testing_template_fill_form_question_before', $question, $q) ?>
<div class="title">
<span class="question-title" style="width:100%;"><?php echo $question->getTitle() ?>
<?php $wp->doAction('wp_testing_template_fill_form_label_end', array('required' => true)) ?></span>
<?php if (!$isMultipleAnswers): ?>
<input type="hidden" name="<?php echo $answerIdName ?>[<?php echo $answerIndex ?>]" value="" />
<?php endif ?>
</div>
<div class="answer-block">
<?php foreach($question->buildAnswers() as $a => $answer): /* #var $answer WpTesting_Model_Answer */ ?>
<?php $answerId = 'wpt-test-question-' . $question->getId() . '-answer-' . $answer->getId() ?>
<div class="answer">
<input type="<?php echo $isMultipleAnswers ? 'checkbox' : 'radio' ?>" id="<?php echo $answerId ?>"
data-errormessage="<?php echo $isMultipleAnswers
? __('Please select at least one answer.', 'wp-testing')
: __('Please choose only one answer.', 'wp-testing') ?>"
<?php if (0 == $a): ?>required="required" aria-required="true"<?php endif ?>
name="<?php echo $answerIdName ?>[<?php echo $answerIndex ?>]" value="<?php echo $answer->getId() ?>" />
</div>
<?php if ($isMultipleAnswers) {$answerIndex++;} ?>
<?php endforeach ?>
</div>
<?php $wp->doAction('wp_testing_template_fill_form_question_after', $question, $q) ?>
<?php if (!$isMultipleAnswers) {$answerIndex++;} ?>
<?php endforeach ?>
</div>
<?php $wp->doAction('wp_testing_template_fill_form_questions_after') ?>
<?php if($isFinal): ?>
<p>
<input type="submit" class="button" value="<?php echo $submitButtonCaption ?>" />
<?php if($stepsCounter): ?><span class="steps-counter"><?php echo $stepsCounter ?></span><?php endif ?>
</p>
<?php else: ?>
<div class="wpt_warning">
<h4><?php echo __('Test is under construction', 'wp-testing') ?></h4>
<p><?php echo __('You can not get any results from it yet.', 'wp-testing') ?></p>
</div>
<?php endif ?>
<?php foreach($hiddens as $name => $value): ?><input type="hidden" name="<?php echo htmlspecialchars($name) ?>" value="<?php echo htmlspecialchars($value) ?>" /><?php endforeach ?>
</form>
</div>
</div>
</div>
<?php else: ?>
<div class="wpt_test fill_form">
<?php if ($isShowContent): ?>
<div class="content">
<?php echo $content ?>
</div>
<?php endif ?>
<div class="content"><form
<?php foreach ($formAttributes as $key => $value):?>
<?php echo $key ?>="<?php echo htmlspecialchars(is_array($value) ? json_encode($value) : $value) ?>"
<?php endforeach ?>>
<?php if ($subTitle): ?><h2 class="subtitle"><?php echo $subTitle ?></h2><?php endif ?>
<?php if ($shortDescription): ?><div class="short-description"><?php echo $wp->autoParagraphise($shortDescription) ?></div><?php endif ?>
<?php $wp->doAction('wp_testing_template_fill_form_questions_before') ?>
<?php foreach($questions as $q => $question): /* #var $question WpTesting_Model_Question */ ?>
<?php $wp->doAction('wp_testing_template_fill_form_question_before', $question, $q) ?>
<div class="question">
<div class="title">
<span class="number"><?php echo $q+1 ?>.</span><span class="title"><?php echo $question->getTitle() ?>
<?php $wp->doAction('wp_testing_template_fill_form_label_end', array('required' => true)) ?></span>
<?php if (!$isMultipleAnswers): ?>
<input type="hidden" name="<?php echo $answerIdName ?>[<?php echo $answerIndex ?>]" value="" />
<?php endif ?>
</div>
<?php foreach($question->buildAnswers() as $a => $answer): /* #var $answer WpTesting_Model_Answer */ ?>
<?php $answerId = 'wpt-test-question-' . $question->getId() . '-answer-' . $answer->getId() ?>
<div class="answer">
<label for="<?php echo $answerId ?>">
<input type="<?php echo $isMultipleAnswers ? 'checkbox' : 'radio' ?>" id="<?php echo $answerId ?>"
data-errormessage="<?php echo $isMultipleAnswers
? __('Please select at least one answer.', 'wp-testing')
: __('Please choose only one answer.', 'wp-testing') ?>"
<?php if (0 == $a): ?>required="required" aria-required="true"<?php endif ?>
name="<?php echo $answerIdName ?>[<?php echo $answerIndex ?>]" value="<?php echo $answer->getId() ?>" />
<?php echo $answer->getTitleOnce() ?>
</label>
</div>
<?php if ($isMultipleAnswers) {$answerIndex++;} ?>
<?php endforeach ?>
</div>
<?php $wp->doAction('wp_testing_template_fill_form_question_after', $question, $q) ?>
<?php if (!$isMultipleAnswers) {$answerIndex++;} ?>
<?php endforeach ?>
<?php $wp->doAction('wp_testing_template_fill_form_questions_after') ?>
<?php if($isFinal): ?>
<p>
<input type="submit" class="button" value="<?php echo $submitButtonCaption ?>" />
<?php if($stepsCounter): ?><span class="steps-counter"><?php echo $stepsCounter ?></span><?php endif ?>
</p>
<?php else: ?>
<div class="wpt_warning">
<h4><?php echo __('Test is under construction', 'wp-testing') ?></h4>
<p><?php echo __('You can not get any results from it yet.', 'wp-testing') ?></p>
</div>
<?php endif ?>
<?php foreach($hiddens as $name => $value): ?><input type="hidden" name="<?php echo htmlspecialchars($name) ?>" value="<?php echo htmlspecialchars($value) ?>" /><?php endforeach ?>
</form></div>
</div>
<?php endif ?>
Related
I'm a noob when it comes to PHP.
However, my employer is asking me to hide the "Add To Cart" button for products in certain categories. I'm wondering if any of you could take a look and help me solve the problem
I appreciate any help you may be able to offer. Unfortunately this task is above my head and the other answers on this don't clearly specify what I need to change.
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
// #codingStandardsIgnoreFile
/** #var $block \Magento\Catalog\Block\Product\View */
?>
<?php
$helper = $this->helper("Lof\RequestForQuote\Helper\Data");
$enable = $helper->isEnabledQuote();
$disable_qty = $helper->getConfig('general/disable_qty');
$disable_qty = ($disable_qty !==null)?(int)$disable_qty:0;
$disable_addtocart = $helper->getConfig('general/disable_addtocart');
$disable_addtocart = ($disable_addtocart !==null)?(int)$disable_addtocart:0;
$enable_addtoquote = $helper->getConfig('general/enable_addtoquote');
$enable_addtoquote = ($enable_addtoquote !==null)?(int)$enable_addtoquote:1;
?>
<?php $_product = $block->getProduct(); ?>
<?php if ($enable && $disable_addtocart && ($enable_addtoquote || ($_product->hasData('product_quote') && $_product->getData('product_quote')))) {
?>
<div class="box-tocart">
<div class="fieldset">
<?php if ($block->shouldRenderQuantity() && !$disable_qty): ?>
<div class="field qty">
<label class="label" for="qty"><span><?= /* #escapeNotVerified */ __('Qty') ?></span></label>
<div class="control">
<input type="number"
name="qty"
id="qty"
value="<?= /* #escapeNotVerified */ $block->getProductDefaultQty() * 1 ?>"
title="<?= /* #escapeNotVerified */ __('Qty') ?>"
class="input-text qty"
data-validate="<?= $block->escapeHtml(json_encode($block->getQuantityValidators())) ?>"
/>
</div>
</div>
<?php endif; ?>
<div class="actions">
<?= $block->getChildHtml('', true) ?>
</div>
</div>
</div>
<?php if ($block->isRedirectToCartEnabled()) : ?>
<script type="text/x-magento-init">
{
"#product_addtocart_form": {
"Magento_Catalog/product/view/validation": {
"radioCheckboxClosest": ".nested"
}
}
}
</script>
<?php else : ?>
<script type="text/x-magento-init">
{
"#product_addtocart_form": {
"Magento_Catalog/js/validate-product": {}
}
}
</script>
<?php endif; ?>
<?php
} else { ?>
<?php $buttonTitle = __('Add to Cart'); ?>
<?php if ($_product->isSaleable()): ?>
<div class="box-tocart">
<div class="fieldset">
<?php if ($block->shouldRenderQuantity()): ?>
<div class="field qty">
<label class="label" for="qty"><span><?= /* #escapeNotVerified */ __('Qty') ?></span></label>
<div class="control">
<input type="number"
name="qty"
id="qty"
value="<?= /* #escapeNotVerified */ $block->getProductDefaultQty() * 1 ?>"
title="<?= /* #escapeNotVerified */ __('Qty') ?>"
class="input-text qty"
data-validate="<?= $block->escapeHtml(json_encode($block->getQuantityValidators())) ?>"
/>
</div>
</div>
<?php endif; ?>
<div class="actions">
<button type="submit"
title="<?= /* #escapeNotVerified */ $buttonTitle ?>"
class="action primary tocart"
id="product-addtocart-button">
<span><?= /* #escapeNotVerified */ $buttonTitle ?></span>
</button>
<?= $block->getChildHtml('', true) ?>
</div>
</div>
</div>
<?php endif; ?>
<?php if ($block->isRedirectToCartEnabled()) : ?>
<script type="text/x-magento-init">
{
"#product_addtocart_form": {
"Magento_Catalog/product/view/validation": {
"radioCheckboxClosest": ".nested"
}
}
}
</script>
<?php else : ?>
<script type="text/x-magento-init">
{
"#product_addtocart_form": {
"Magento_Catalog/js/validate-product": {}
}
}
</script>
<?php endif; ?>
<?php } ?>
This question already has answers here:
PHP parse/syntax errors; and how to solve them
(20 answers)
Closed 5 years ago.
I am getting this error
Parse error: syntax error, unexpected 'endforeach' (T_ENDFOREACH),
expecting elseif (T_ELSEIF) or else (T_ELSE) or endif (T_ENDIF) in
/var/www/html/app/design/frontend/nego/nego_default/Magento_Catalog/templates/product/list.phtml
on line 130
list.phtml shows this:
<?php
/**
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
use Magento\Framework\App\Action\Action;
// #codingStandardsIgnoreFile
?>
<?php
/**
* Product list template
*
* #var $block \Magento\Catalog\Block\Product\ListProduct
*/
?>
<?php
$_productCollection = $block->getLoadedProductCollection();
$_helper = $this->helper('Magento\Catalog\Helper\Output');
?>
<?php if (!$_productCollection->count()): ?>
<div class="message info empty"><div><?php /* #escapeNotVerified */ echo __('We can\'t find products matching the selection.') ?></div></div>
<?php else: ?>
<?php echo $block->getToolbarHtml() ?>
<?php echo $block->getAdditionalHtml() ?>
<?php
if ($block->getMode() == 'grid') {
$viewMode = 'grid';
$image = 'category_page_grid';
$showDescription = false;
$templateType = \Magento\Catalog\Block\Product\ReviewRendererInterface::SHORT_VIEW;
} else {
$viewMode = 'list';
$image = 'category_page_list';
$showDescription = true;
$templateType = \Magento\Catalog\Block\Product\ReviewRendererInterface::FULL_VIEW;
}
/**
* Position for actions regarding image size changing in vde if needed
*/
$pos = $block->getPositioned();
?>
<div class="products wrapper <?php /* #escapeNotVerified */ echo $viewMode; ?> products-<?php /* #escapeNotVerified */ echo $viewMode; ?>">
<?php $iterator = 1; ?>
<ol class="products list items product-items">
<?php /** #var $_product \Magento\Catalog\Model\Product */ ?>
<?php foreach ($_productCollection as $_product): ?>
<?php /* #escapeNotVerified */ echo($iterator++ == 1) ? '<li class="item product product-item">' : '</li><li class="item product product-item">' ?>
<div class="product-item-info" data-container="product-grid">
<div class=" product-item-images">
<?php
$newFromDate = $_product->getNewsFromDate();
$newToDate = $_product->getNewsToDate();
$now = date("Y-m-d H:m:s");
// Get the Special Price
$specialprice = $_product->getSpecialPrice();
// Get the Special Price FROM date
$specialPriceFromDate = $_product->getSpecialFromDate();
// Get the Special Price TO date
$specialPriceToDate = $_product->getSpecialToDate();
// Get Current date
if ($specialprice&&(($specialPriceFromDate <= $now && $specialPriceToDate >= $now) || (($specialPriceFromDate <= $now && $specialPriceFromDate != NULL) && $specialPriceToDate == ''))){
$_savePercent = 100 - round(($_product->getSpecialPrice() / $_product->getPrice())*100);
echo "<span class='hot-sale'>-".$_savePercent."%</span>";
}else{
if((($newFromDate <= $now && $newToDate >= $now) || (($newFromDate <= $now && $newFromDate != NULL) && $newToDate == NULL))) {
?>
<div class="label-pro-new"><span><?php echo __('new!') ?></span></div>
<?php
}
}
?>
<?php
$productImage = $block->getImage($_product, $image);
if ($pos != null) {
$position = ' style="left:' . $productImage->getWidth() . 'px;'
. 'top:' . $productImage->getHeight() . 'px;"';
}
?>
<?php // Product Image ?>
<a href="<?php /* #escapeNotVerified */ echo $_product->getProductUrl() ?>" class="product photo product-item-photo" tabindex="-1">
<?php echo $productImage->toHtml(); ?>
</a>
</div>
<div class="product-item-details">
<?php
$_productNameStripped = $block->stripTags($_product->getName(), null, true);
?>
<strong class="product name product-item-name">
<a class="product-item-link"
href="<?php /* #escapeNotVerified */ echo $_product->getProductUrl() ?>">
<?php /* #escapeNotVerified */ echo $_helper->productAttribute($_product, $_product->getName(), 'name'); ?>
</a>
</strong>
<?php echo $block->getReviewsSummaryHtml($_product, $templateType); ?>
<?php /* #escapeNotVerified */ echo $block->getProductPrice($_product) ?>
<?php echo $block->getProductDetailsHtml($_product); ?>
<?php if ($showDescription):?>
<div class="product description product-item-description">
<?php /* #escapeNotVerified */ echo $_helper->productAttribute($_product, $_product->getShortDescription(), 'short_description') ?>
<a href="<?php /* #escapeNotVerified */ echo $_product->getProductUrl() ?>" title="<?php /* #escapeNotVerified */ echo $_productNameStripped ?>"
class="action more"><?php /* #escapeNotVerified */ echo __('Learn More') ?></a>
</div>
<?php endif; ?>
<div class="product-item-actions"<?php echo strpos($pos, $viewMode . '-actions') ? $position : ''; ?>>
<div class="add-to-cart-primary"<?php echo strpos($pos, $viewMode . '-primary') ? $position : ''; ?>>
<?php if ($_product->isSaleable()): ?>
<?php $postParams = $block->getAddToCartPostParams($_product); ?>
<form data-role="tocart-form" action="<?php /* #escapeNotVerified */ echo $postParams['action']; ?>" method="post">
<input type="hidden" name="product" value="<?php /* #escapeNotVerified */ echo $postParams['data']['product']; ?>">
<input type="hidden" name="<?php /* #escapeNotVerified */ echo Action::PARAM_NAME_URL_ENCODED; ?>" value="<?php /* #escapeNotVerified */ echo $postParams['data'][Action::PARAM_NAME_URL_ENCODED]; ?>">
<?php echo $block->getBlockHtml('formkey')?>
<button type="submit"
title="<?php echo $block->escapeHtml(__('Add to Cart')); ?>"
class="tocart">
<span><?php /* #escapeNotVerified */ echo __('Add to Cart') ?></span>
</button>
</form>
</div>
</div>
</div>
</div>
<?php echo($iterator == count($_productCollection)+1) ? '</li>' : '' ?>
<?php endforeach; ?>
</ol>
</div>
<?php echo $block->getToolbarHtml() ?>
<?php if (!$block->isRedirectToCartEnabled()) : ?>
<script type="text/x-magento-init">
{
"[data-role=tocart-form], .form.map.checkout": {
"catalogAddToCart": {}
}
}
</script>
<?php endif; ?>
<?php endif; ?>
All other pages works. But the category pages shows error.
You didn't close "if" statement started in line 111. Just add it after line 123.
<?php
/**
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
use Magento\Framework\App\Action\Action;
// #codingStandardsIgnoreFile
?>
<?php
/**
* Product list template
*
* #var $block \Magento\Catalog\Block\Product\ListProduct
*/
?>
<?php
$_productCollection = $block->getLoadedProductCollection();
$_helper = $this->helper('Magento\Catalog\Helper\Output');
?>
<?php if (!$_productCollection->count()): ?>
<div class="message info empty"><div><?php /* #escapeNotVerified */ echo __('We can\'t find products matching the selection.') ?></div></div>
<?php else: ?>
<?php echo $block->getToolbarHtml() ?>
<?php echo $block->getAdditionalHtml() ?>
<?php
if ($block->getMode() == 'grid') {
$viewMode = 'grid';
$image = 'category_page_grid';
$showDescription = false;
$templateType = \Magento\Catalog\Block\Product\ReviewRendererInterface::SHORT_VIEW;
} else {
$viewMode = 'list';
$image = 'category_page_list';
$showDescription = true;
$templateType = \Magento\Catalog\Block\Product\ReviewRendererInterface::FULL_VIEW;
}
/**
* Position for actions regarding image size changing in vde if needed
*/
$pos = $block->getPositioned();
?>
<div class="products wrapper <?php /* #escapeNotVerified */ echo $viewMode; ?> products-<?php /* #escapeNotVerified */ echo $viewMode; ?>">
<?php $iterator = 1; ?>
<ol class="products list items product-items">
<?php /** #var $_product \Magento\Catalog\Model\Product */ ?>
<?php foreach ($_productCollection as $_product): ?>
<?php /* #escapeNotVerified */ echo($iterator++ == 1) ? '<li class="item product product-item">' : '</li><li class="item product product-item">' ?>
<div class="product-item-info" data-container="product-grid">
<div class=" product-item-images">
<?php
$newFromDate = $_product->getNewsFromDate();
$newToDate = $_product->getNewsToDate();
$now = date("Y-m-d H:m:s");
// Get the Special Price
$specialprice = $_product->getSpecialPrice();
// Get the Special Price FROM date
$specialPriceFromDate = $_product->getSpecialFromDate();
// Get the Special Price TO date
$specialPriceToDate = $_product->getSpecialToDate();
// Get Current date
if ($specialprice&&(($specialPriceFromDate <= $now && $specialPriceToDate >= $now) || (($specialPriceFromDate <= $now && $specialPriceFromDate != NULL) && $specialPriceToDate == ''))){
$_savePercent = 100 - round(($_product->getSpecialPrice() / $_product->getPrice())*100);
echo "<span class='hot-sale'>-".$_savePercent."%</span>";
}else{
if((($newFromDate <= $now && $newToDate >= $now) || (($newFromDate <= $now && $newFromDate != NULL) && $newToDate == NULL))) {
?>
<div class="label-pro-new"><span><?php echo __('new!') ?></span></div>
<?php
}
}
?>
<?php
$productImage = $block->getImage($_product, $image);
if ($pos != null) {
$position = ' style="left:' . $productImage->getWidth() . 'px;'
. 'top:' . $productImage->getHeight() . 'px;"';
}
?>
<?php // Product Image ?>
<a href="<?php /* #escapeNotVerified */ echo $_product->getProductUrl() ?>" class="product photo product-item-photo" tabindex="-1">
<?php echo $productImage->toHtml(); ?>
</a>
</div>
<div class="product-item-details">
<?php
$_productNameStripped = $block->stripTags($_product->getName(), null, true);
?>
<strong class="product name product-item-name">
<a class="product-item-link"
href="<?php /* #escapeNotVerified */ echo $_product->getProductUrl() ?>">
<?php /* #escapeNotVerified */ echo $_helper->productAttribute($_product, $_product->getName(), 'name'); ?>
</a>
</strong>
<?php echo $block->getReviewsSummaryHtml($_product, $templateType); ?>
<?php /* #escapeNotVerified */ echo $block->getProductPrice($_product) ?>
<?php echo $block->getProductDetailsHtml($_product); ?>
<?php if ($showDescription):?>
<div class="product description product-item-description">
<?php /* #escapeNotVerified */ echo $_helper->productAttribute($_product, $_product->getShortDescription(), 'short_description') ?>
<a href="<?php /* #escapeNotVerified */ echo $_product->getProductUrl() ?>" title="<?php /* #escapeNotVerified */ echo $_productNameStripped ?>"
class="action more"><?php /* #escapeNotVerified */ echo __('Learn More') ?></a>
</div>
<?php endif; ?>
<div class="product-item-actions"<?php echo strpos($pos, $viewMode . '-actions') ? $position : ''; ?>>
<div class="add-to-cart-primary"<?php echo strpos($pos, $viewMode . '-primary') ? $position : ''; ?>>
<?php if ($_product->isSaleable()): ?>
<?php $postParams = $block->getAddToCartPostParams($_product); ?>
<form data-role="tocart-form" action="<?php /* #escapeNotVerified */ echo $postParams['action']; ?>" method="post">
<input type="hidden" name="product" value="<?php /* #escapeNotVerified */ echo $postParams['data']['product']; ?>">
<input type="hidden" name="<?php /* #escapeNotVerified */ echo Action::PARAM_NAME_URL_ENCODED; ?>" value="<?php /* #escapeNotVerified */ echo $postParams['data'][Action::PARAM_NAME_URL_ENCODED]; ?>">
<?php echo $block->getBlockHtml('formkey')?>
<button type="submit"
title="<?php echo $block->escapeHtml(__('Add to Cart')); ?>"
class="tocart">
<span><?php /* #escapeNotVerified */ echo __('Add to Cart') ?></span>
</button>
</form>
<?php endif; ?>
</div>
</div>
</div>
</div>
<?php echo($iterator == count($_productCollection)+1) ? '</li>' : '' ?>
<?php endforeach; ?>
</ol>
</div>
<?php echo $block->getToolbarHtml() ?>
<?php if (!$block->isRedirectToCartEnabled()) : ?>
<script type="text/x-magento-init">
{
"[data-role=tocart-form], .form.map.checkout": {
"catalogAddToCart": {}
}
}
</script>
<?php endif; ?>
<?php endif; ?>
How To Show "Shop By" left sidebar attribute list in "Dropdown" like as "Sort By" Toolbar?
I want to show attribute list same as "Sort By" Toolbar as Dropdown list.
my toolbar.phtml code is
<?php
/**
* Magento
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE_AFL.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license#magentocommerce.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade Magento to newer
* versions in the future. If you wish to customize Magento for your
* needs please refer to http://www.magentocommerce.com for more information.
*
* #category design
* #package base_default
* #copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
* #license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
*/
?>
<?php
/**
* Product list toolbar
*
* #see Mage_Catalog_Block_Product_List_Toolbar
*/
?>
<?php
/**
* - Pager moved after sorter. Show pager only if there are pages.
* - Amount and limiter moved inside sorter
* - Changed order of the main elements
*/
?>
<?php if($this->getCollection()->getSize()): ?>
<div class="toolbar">
<?php if( $this->isExpanded() ): ?>
<div class="sorter">
<p class="amount">
<?php if($this->getLastPageNum()>1): ?>
<?php echo $this->__('Items %s to %s of %s total', $this->getFirstNum(), $this->getLastNum(), $this->getTotalNum()) ?>
<?php else: ?>
<strong><?php echo $this->__('%s Item(s)', $this->getTotalNum()) ?></strong>
<?php endif; ?>
</p>
<div class="sort-by">
<label><?php echo $this->__('Sort By') ?></label>
<select onchange="setLocation(this.value)">
<?php foreach($this->getAvailableOrders() as $_key=>$_order): ?>
<option value="<?php echo $this->getOrderUrl($_key, 'asc') ?>"<?php if($this->isOrderCurrent($_key)): ?> selected="selected"<?php endif; ?>>
<?php echo $this->__($_order) ?>
</option>
<?php endforeach; ?>
</select>
<?php if($this->getCurrentDirection() == 'desc'): ?>
<a class="category-desc ic ic-arrow-up" href="<?php echo $this->getOrderUrl(null, 'asc') ?>" title="<?php echo $this->__('Set Ascending Direction') ?>"></a>
<?php else: ?>
<a class="category-asc ic ic-arrow-down" href="<?php echo $this->getOrderUrl(null, 'desc') ?>" title="<?php echo $this->__('Set Descending Direction') ?>"></a>
<?php endif; ?>
</div>
<div class="sort-by">
<label><?php echo $this->__('Sort By') ?></label>
<select onchange="setLocation(this.value)">
<?php foreach($this->getAvailableOrders() as $_key=>$_order): ?>
<option value="<?php echo $this->getOrderUrl($_key, 'asc') ?>"<?php if($this->isOrderCurrent($_key)): ?> selected="selected"<?php endif; ?>>
<?php echo $this->__($_order) ?>
</option>
<?php endforeach; ?>
</select>
<?php if($this->getCurrentDirection() == 'desc'): ?>
<a class="category-desc ic ic-arrow-up" href="<?php echo $this->getOrderUrl(null, 'asc') ?>" title="<?php echo $this->__('Set Ascending Direction') ?>"></a>
<?php else: ?>
<a class="category-asc ic ic-arrow-down" href="<?php echo $this->getOrderUrl(null, 'desc') ?>" title="<?php echo $this->__('Set Descending Direction') ?>"></a>
<?php endif; ?>
</div>
<div class="limiter">
<label><?php echo $this->__('Show') ?></label>
<select onchange="setLocation(this.value)">
<?php foreach ($this->getAvailableLimit() as $_key=>$_limit): ?>
<option value="<?php echo $this->getLimitUrl($_key) ?>"<?php if($this->isLimitCurrent($_key)): ?> selected="selected"<?php endif ?>>
<?php echo $_limit ?>
</option>
<?php endforeach; ?>
</select><span class="per-page"> <?php echo $this->__('per page'); ?></span>
</div>
<?php if( $this->isEnabledViewSwitcher() ): ?>
<p class="view-mode">
<?php $_modes = $this->getModes(); ?>
<?php if($_modes && count($_modes)>1): ?>
<label><?php echo $this->__('View as') ?>:</label>
<?php //Removed spaces from the foreach loop to improve layout of the buttons ?>
<?php foreach ($this->getModes() as $_code=>$_label): ?><?php $codeToLower = strtolower($_code); if($this->isModeActive($_code)): ?><span title="<?php echo $_label ?>" class="<?php echo $codeToLower; ?> ic ic-<?php echo $codeToLower; ?>"></span><?php else: ?><?php endif; ?><?php endforeach; ?>
<?php endif; ?>
</p>
<?php endif; ?>
</div> <!-- end: sorter -->
<?php endif; ?>
<?php //Show pager only if there are pages ?>
<?php if ($pagerHtml = trim($this->getPagerHtml())): ?>
<div class="pager">
<?php echo $pagerHtml; ?>
</div>
<?php endif; ?>
</div>
<?php endif ?>
list.phtml code is
<?php
/**
* Magento
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE_AFL.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license#magentocommerce.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade Magento to newer
* versions in the future. If you wish to customize Magento for your
* needs please refer to http://www.magentocommerce.com for more information.
*
* #category design
* #package base_default
* #copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
* #license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
*/
?>
<?php
/**
* Product list template
*
* #see Mage_Catalog_Block_Product_List
*/
?>
<?php
$_productCollection=$this->getLoadedProductCollection();
$_collectionSize = $_productCollection->count();
?>
<?php if ($_collectionSize && $tmpHtml = $this->getChildHtml('block_category_above_collection')): ?>
<div class="block_category_above_collection std"><?php echo $tmpHtml; ?></div>
<?php endif; ?>
<?php if(!$_collectionSize): ?>
<?php if ($tmpHtml = $this->getChildHtml('block_category_above_empty_collection')): ?>
<div class="block_category_above_empty_collection std"><?php echo $tmpHtml; ?></div>
<?php else: ?>
<p class="note-msg empty-catalog"><?php echo $this->__('There are no products matching the selection.') ?></p>
<?php endif; ?>
<?php else: ?>
<?php
$_helper = $this->helper('catalog/output');
$theme = $this->helper('ultimo');
$helpLabels = $this->helper('ultimo/labels');
$helpTemplate = $this->helper('ultimo/template');
$helpImg = $this->helper('infortis/image');
//Default image size
$imgWidth = 295;
$imgHeight = 295;
//Aspect ratio settings
if ($theme->getCfg('category/aspect_ratio'))
$imgHeight = 0; //Height will be computed automatically (based on width) to keep the aspect ratio
//Hide toolbar
$hideToolbar = false;
if ($this->getHideToolbar())
{
$hideToolbar = true;
}
?>
<div class="category-products">
<?php if (!$hideToolbar): ?>
<?php echo $this->getToolbarHtml() ?>
<?php endif; ?>
<?php if($this->getMode()!='grid'): //List mode ?>
<?php
//Get list configuration array
$lc = $theme->getCfgGroup('category_list');
//List classes
$listClasses = '';
if ($lc['hover_effect'])
$listClasses = ' hover-effect';
?>
<?php $_iterator = 0; ?>
<ul class="products-list<?php if($listClasses) echo $listClasses; ?>" id="products-list">
<?php foreach ($_productCollection as $_product): ?>
<li class="item<?php if( ++$_iterator == sizeof($_productCollection) ): ?> last<?php endif; ?>">
<?php //Product Image ?>
<div class="product-image-wrapper grid12-4 mobile-grid-half">
<a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" class="product-image" style="max-width:<?php echo $imgWidth; ?>px;">
<img src="<?php echo $helpImg->getImg($_product, $imgWidth, $imgHeight, 'small_image'); ?>" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" />
<?php if ($theme->getCfg('category/alt_image')): ?>
<?php echo $theme->getAltImgHtml($_product, $imgWidth, $imgHeight); ?>
<?php endif; ?>
<?php echo $helpLabels->getLabels($_product); //Product labels ?>
</a>
</div> <!-- end: product-image-wrapper -->
<?php //Product description ?>
<div class="product-shop grid12-5 mobile-grid-half">
<div class="product-shop-inner">
<?php $_productNameStripped = $this->stripTags($_product->getName(), null, true); ?>
<h2 class="product-name"><?php echo $_helper->productAttribute($_product, $_product->getName() , 'name'); ?></h2>
<?php if($_product->getRatingSummary()): ?>
<?php echo $this->getReviewsSummaryHtml($_product, 'short') ?>
<?php endif; ?>
<div class="desc std">
<?php echo $_helper->productAttribute($_product, $_product->getShortDescription(), 'short_description') ?>
<?php echo $this->__('Learn More') ?>
</div>
</div>
</div>
<div class="right-column grid12-3 mobile-grid-half">
<?php echo $this->getPriceHtml($_product, true) ?>
<?php if($_product->isSaleable()): ?>
<p><button type="button" title="<?php echo $this->__('Add to Cart') ?>" class="button btn-cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button></p>
<?php else: ?>
<p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p>
<?php endif; ?>
<?php
if ($lc['addtolinks_simple'])
echo $helpTemplate->getCategoryAddtoLinks($_product, $this->getAddToCompareUrl($_product), 'addto-gaps-right');
else
echo $helpTemplate->getCategoryAddtoLinksComplex($_product, $this->getAddToCompareUrl($_product), 'addto-gaps-right');
?>
</div>
</li>
<?php endforeach; ?>
</ul>
<script type="text/javascript">decorateList('products-list', 'none-recursive')</script>
<?php else: //Grid mode ?>
<?php
//Get grid configuration array
$gc = $theme->getCfgGroup('category_grid');
//Get number of columns (from parameter or from theme config)
$columnCount = 3;
if ($this->getGridColumnCount())
{
$columnCount = $this->getGridColumnCount();
}
else
{
$columnCount = $gc['column_count'];
}
//Grid classes
$gridClasses = '';
$productNameClasses = '';
if ($gc['display_name'] == 2 && $gc['display_name_single_line'] == true)
$gridClasses .= ' single-line-name';
if ($gc['display_name'] == 1)
$productNameClasses .= ' display-onhover';
if ($gc['centered'])
$gridClasses .= ' centered';
if ($gc['hover_effect'])
$gridClasses .= ' hover-effect';
if ($gc['equal_height'])
$gridClasses .= ' equal-height';
//Size of grid elements
if ($gc['elements_size'])
{
$gridClasses .= ' size-' . $gc['elements_size'];
}
else
{
//Calculate size based on number of columns
if ($columnCount >= 6)
{
$gridClasses .= ' size-xs';
}
elseif ($columnCount >= 4)
{
$gridClasses .= ' size-s';
}
}
//Container "actions" at the bottom of the grid item stores button and add-to links
//If at least one of those elements was set as "Display on hover" but no element was set as "Display":
//apply appropriate classes to the container.
$actionsClasses = '';
if ($gc['display_addtocart'] == 1 || ($gc['display_addtolinks'] == 1 && !$gc['addtolinks_simple']))
{
$actionsClasses = ' display-onhover';
}
if ($gc['display_addtocart'] == 2 || ($gc['display_addtolinks'] == 2 && !$gc['addtolinks_simple']))
{
$actionsClasses = '';
}
?>
<ul class="products-grid category-products-grid itemgrid itemgrid-adaptive itemgrid-<?php echo $columnCount; ?>col<?php if($gridClasses) echo $gridClasses; ?>">
<?php foreach ($_productCollection as $_product): ?>
<li class="item">
<div class="product-image-wrapper" style="max-width:<?php echo $imgWidth; ?>px;">
<a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true); ?>" class="product-image">
<img src="<?php echo $helpImg->getImg($_product, $imgWidth, $imgHeight, 'small_image'); ?>" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true); ?>" />
<?php if ($theme->getCfg('category/alt_image')): ?>
<?php echo $theme->getAltImgHtml($_product, $imgWidth, $imgHeight); ?>
<?php endif; ?>
<?php echo $helpLabels->getLabels($_product); //Product labels ?>
</a>
<?php //Add-to links
if ($gc['display_addtolinks'] != 0 && $gc['addtolinks_simple'])
{
if ($gc['display_addtolinks'] == 1) //Display on hover
echo $helpTemplate->getCategoryAddtoLinksIcons($_product, $this->getAddToCompareUrl($_product), 'addto-links-icons addto-onimage display-onhover');
else //Always display
echo $helpTemplate->getCategoryAddtoLinksIcons($_product, $this->getAddToCompareUrl($_product), 'addto-links-icons addto-onimage');
}
?>
</div> <!-- end: product-image-wrapper -->
<?php if ($gc['display_name'] != 0): ?>
<h2 class="product-name<?php echo $productNameClasses; ?>"><?php echo $_helper->productAttribute($_product, $_product->getName(), 'name') ?></h2>
<?php endif; ?>
<?php if ($_product->getRatingSummary()): ?>
<?php if ($gc['display_rating'] == 1): //Display on hover ?>
<div class="display-onhover ratings-wrapper"><?php echo $this->getReviewsSummaryHtml($_product, 'short') ?></div>
<?php elseif ($gc['display_rating'] == 2): //Always display ?>
<?php echo $this->getReviewsSummaryHtml($_product, 'short') ?>
<?php endif; ?>
<?php endif; ?>
<?php if ($gc['display_price'] == 1): //Display on hover ?>
<div class="display-onhover"><?php echo $this->getPriceHtml($_product, true); ?></div>
<?php elseif ($gc['display_price'] == 2): //Always display ?>
<?php echo $this->getPriceHtml($_product, true); ?>
<?php endif; ?>
<?php
//If at least one element was set as "Display on hover" but no element was set as "Display":
//aggregate classes from those elements and apply them to the "actions" container.
$actionsClasses = '';
if ($gc['display_addtocart'] == 1 || ($gc['display_addtolinks'] == 1 && !$gc['addtolinks_simple']))
{
$actionsClasses = ' display-onhover';
}
if ($gc['display_addtocart'] == 2 || ($gc['display_addtolinks'] == 2 && !$gc['addtolinks_simple']))
{
$actionsClasses = '';
}
?>
<div class="actions clearer<?php echo $actionsClasses; ?>">
<?php //Cart button ?>
<?php if ($gc['display_addtocart'] != 0): ?>
<?php if ($_product->isSaleable()): ?>
<button type="button" title="<?php echo $this->__('Add to Cart') ?>" class="button btn-cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button>
<?php else: ?>
<p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p>
<?php endif; ?>
<?php endif; ?>
<?php //Add-to links
if ($gc['display_addtolinks'] != 0 && !$gc['addtolinks_simple'])
{
echo $helpTemplate->getCategoryAddtoLinks($_product, $this->getAddToCompareUrl($_product), 'addto-gaps-right');
}
?>
</div> <!-- end: actions -->
</li>
<?php endforeach; ?>
</ul>
<?php endif; //end: if grid mode ?>
<?php if (!$hideToolbar): ?>
<div class="toolbar-bottom">
<?php echo $this->getToolbarHtml() ?>
</div>
<?php endif; ?>
</div>
<?php endif; ?>
<?php if ($_collectionSize && $tmpHtml = $this->getChildHtml('block_category_below_collection')): ?>
<div class="block_category_below_collection std"><?php echo $tmpHtml; ?></div>
<?php endif; ?>
I started learning PHP/CSS/HTML5 & Java a month ago and I'm currently setting up an online shop for my new home business. I'm using opencart, but i'm having difficulty with transforming some of the PHP in terms of getting it to display side by side.
This is how I would like it to look.
Price: $000.00000
<table width="200" border="0">
<tr>
<td>Option 1</td>
<td>Option 2</td>
</tr>
<tr>
<td>1</td>
<td>1</td>
</tr>
<tr>
<td>2</td>
<td>2</td>
</tr>
<tr>
<td>3</td>
<td>3</td>
</tr>
</table>
I've figured out how to do this in CSS, but the required radio radio buttons (see the code below) is the same code for option 1 & 2.
It currently looks like this
Price $000.0000
Option 1
1
2
3
Option 2
1
2
3
<?php if ($price) { ?>
<div class="price">
<span class="text-price"><?php echo $text_price; ?></span>
<?php if (!$special) { ?>
<span class="price-new"><?php echo $price; ?> <span style="font-size:10px;">pp</span></span>
<?php } else { ?>
<span class="price-new"><?php echo $special; ?></span><span class="price-old"><?php echo $price; ?></span>
<?php } ?>
<?php if ($tax) { ?>
<span class="price-tax"><?php echo $text_tax; ?> <?php echo $tax; ?></span>
<?php } ?>
<?php if ($points) { ?>
<span class="reward"><small><?php echo $text_points; ?> <?php echo $points; ?></small></span>
<?php } ?>
<?php if ($discounts) { ?>
<div class="discount">
<?php foreach ($discounts as $discount) { ?>
<?php echo sprintf($text_discount, $discount['quantity'], $discount['price']); ?><br />
<?php } ?>
</div>
<?php } ?>
</div>
<?php } ?>
<?php if ($profiles): ?>
<div class="option">
<h2><span class="required">*</span><?php echo $text_payment_profile ?></h2>
<br />
<select name="profile_id">
<option value=""><?php echo $text_select; ?></option>
<?php foreach ($profiles as $profile): ?>
<option value="<?php echo $profile['profile_id'] ?>"><?php echo $profile['name'] ?></option>
<?php endforeach; ?>
</select>
<br />
<br />
<span id="profile-description"></span>
<br />
<br />
</div>
<?php endif; ?>
<?php if ($options) { ?>
<div class="options">
<h2><?php echo $text_option; ?></h2>
<?php foreach ($options as $option) { ?>
<?php if ($option['type'] == 'select') { ?>
<div id="option-<?php echo $option['product_option_id']; ?>" class="option">
<label><?php if ($option['required']) { ?>
<span class="required">*</span>
<?php } ?>
<b><?php echo $option['name']; ?>:</b></label>
<select name="option[<?php echo $option['product_option_id']; ?>]">
<option value=""><?php echo $text_select; ?></option>
<?php foreach ($option['option_value'] as $option_value) { ?>
<option value="<?php echo $option_value['product_option_value_id']; ?>"><?php echo $option_value['name']; ?>
<?php if ($option_value['price']) { ?>
(<?php echo $option_value['price_prefix']; ?><?php echo $option_value['price']; ?>)
<?php } ?>
</option>
<?php } ?>
</select>
</div>
<?php } ?>
<?php if ($option['type'] == 'radio') { ?>
<div id="option-<?php echo $option['product_option_id']; ?>" class="option">
<label>
<?php if ($option['required']) { ?>
<span class="required">*</span>
<?php } ?>
<b><?php echo $option['name']; ?>:</b></label>
<?php foreach ($option['option_value'] as $option_value) { ?>
<label class="radio" for="option-value-<?php echo $option_value['product_option_value_id']; ?>">
<input type="radio" name="option[<?php echo $option['product_option_id']; ?>]" value="<?php echo $option_value['product_option_value_id']; ?>" id="option-value-<?php echo $option_value['product_option_value_id']; ?>" /><?php echo $option_value['name']; ?>
<?php if ($option_value['price']) { ?>
(<?php echo $option_value['price_prefix']; ?><?php echo $option_value['price']; ?>)
<?php } ?>
</label>
<?php } ?>
Why don't you display your table dynamically and then simply style it in CSS using nth-child(#)? You can simply loop through an array and display echo each row before closing out the table after.
This is my methods.phtml file in onepagecheckout in magento,I want the dropdown(select option) button instead of radio button .........so that i could select the payment method to pay the payment.
<?php if (!$methods = $this->getMethods()) : ?>
<p><?php echo $this->helper('checkout')->__('Sorry, no quotes are available for this order at this time.') ?></p>
<?php else : ?>
<dl class="sp-methods">
<?php foreach ($this->getMethods() as $_method): $_code = $_method->getCode() ?>
<dt>
<?php if( sizeof($this->getMethods()) > 1 ): ?>
<input value="<?php echo $_code ?>" type="radio" name="payment[method]" title="<?php echo $this->htmlEscape($_method->getTitle()) ?>" onclick="payment.switchMethod('<?php echo $_code ?>')"<?php if($this->getSelectedMethodCode()==$_code): ?> checked="checked"<?php endif; ?> class="radio" />
<?php else: ?>
<span class="no-display"><input id="p_method_<?php echo $_code ?>" value="<?php echo $_code ?>" type="radio" name="payment[method]" checked="checked" class="radio" /> </span>
<?php endif; ?>
<label for="p_method_<?php echo $_code ?>"><?php echo $this->htmlEscape($_method->getTitle()) ?> <?php echo $this->getMethodLabelAfterHtml($_method) ?></label>
</dt>
<?php if ($html = $this->getPaymentMethodFormHtml($_method)): ?>
<dd>
<?php echo $html; ?>
</dd>
<?php endif; ?>
<?php endforeach; ?>
</dl>
<script type="text/javascript">
//<![CDATA[
<?php echo $this->getChildChildHtml('scripts'); ?>
payment.init();
//]]>
</script>
<?php endif; ?>
You can do the select option dropdown for payment method as setup below code in methods.phtml file.
Also you have to changes in opcheckout.js line no 715 to change "elements[i].checked" to "elements[i].value".
<?php
$methods = $this->getMethods();
$oneMethod = count($methods) <= 1;
?>
<?php if (empty($methods)): ?>
<dt>
<?php echo $this->__('No Payment Methods') ?>
</dt>
<?php else:
?>
<dt>Select Payment Method:</dt>
<select name="payment[method]" onchange="payment.switchMethod(this.value);">
<?php
foreach ($methods as $_method):
$_code = $_method->getCode();
?>
<option id="p_method_<?php echo $_code ?>" value="<?php echo $_code ?>" <?php if($this->getSelectedMethodCode()==$_code): ?> selected="selected"<?php endif; ?>>
<?php echo $this->escapeHtml($this->getMethodTitle($_method)) ?> <?php echo $this->getMethodLabelAfterHtml($_method) ?>
</option>
<?php endforeach; ?>
</select>
<?php
foreach ($methods as $_method):
$_code = $_method->getCode();
?>
<?php if ($html = $this->getPaymentMethodFormHtml($_method)): ?>
<dd id="dd_method_<?php echo $_code ?>">
<?php echo $html; ?>
</dd>
<?php endif;
endforeach;
endif;
?>
<?php echo $this->getChildChildHtml('additional'); ?>
<script type="text/javascript">
//<![CDATA[
<?php echo $this->getChildChildHtml('scripts'); ?>
payment.init();
<?php if (is_string($oneMethod)): ?>
payment.switchMethod('<?php echo $oneMethod ?>');
<?php endif; ?>
//]]>
</script>
I used this one to get my select list if helpful
<?php
$ptId1=mysql_query(" some query here")
echo"<select name=ptId>";
while($ptId=mysql_fetch_array($ptId1))
{
echo '<option value="'.$ptId['id'].'">'.$ptId['id'].'</option>';
}
echo '</select>';?>
}