I have the option named artwork which has 3 values (We Design Single, We Design Double, Upload Artwork).
I want to edit the view product.tbl to format the "We Design Single" and "We Design Double" So it only shows as "We Design".
I think this is the part of the code i need to edit but unsure how
<div id="option-<?php echo $option['product_option_id']; ?>" class="option">
<?php if ($option['required']) { ?>
<span class="required">*</span>
<?php } ?>
<b><?php echo $option['name']; ?>:</b><br />
<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']; ?><span id="newPrice"><?php echo
$option_value['price']; ?></span>)
<?php } ?>
</option>
<?php } ?>
</select>
</div>
I think you would use an if statement to determine if the 'product_option_value_id' == 'We Design Single' || 'product_option_value_id'=='We Design Single' then use substr() to display only part of 'product_option_value_id'.
Any Ideas?
<?php if ($option_value['name'] == 'We Design Single' || $option_value['name'] == 'We Design Double') { ?>
<option value="<?php echo $option_value['product_option_value_id']; ?>"><?php echo "We Design" ?>
<?php } else { ?>
<option value="<?php echo $option_value['product_option_value_id']; ?>"><?php echo $option_value['name']; ?>
<?php } ?>
Got it working anyway
Related
I am using Opencart 2.2.0 on Journal theme. I am using super filter to display attributes. The problem is - this filter only displays as check box. I need it to display as drop down. The theme maker told me that module only shows in check box option, but I am wondering if I can make it display as drop down instead. The code for super_filter_attributes.tpl is:
<div class="box sf-attribute sf-attribute-<?php echo $attribute['attribute_id']; ?> sf-<?php echo $attribute['type']; ?>">
<div class="box-heading"><?php echo $attribute['attribute_name']; ?></div>
<div class="box-content">
<ul class="<?php echo $this->journal2->settings->get('filter_show_box') ? '' : 'hide-checkbox'; ?>">
<?php foreach ($attribute['values'] as $value) { ?>
<li><label><input data-keyword="<?php echo $value['keyword']?>" type="checkbox" name="attribute[<?php echo $attribute['attribute_id']?>]" value="<?php echo $value['text']; ?>"><?php echo $value['name']; ?></label></li>
<?php } ?>
</ul>
</div>
I edited a bit and now my code looks like this:
<div class="box sf-attribute sf-attribute-<?php echo $attribute['attribute_id']; ?> sf-<?php echo $attribute['type']; ?>">
<div class="box-heading"><?php echo $attribute['attribute_name']; ?></div>
<div class="box-content">
<ul class="<?php echo $this->journal2->settings->get('filter_show_box') ? '' : 'hide-checkbox'; ?>">
<div class="box sf-attribute sf-attribute-<?php echo $attribute['attribute_id']; ?> sf-<?php echo $attribute['type']; ?>">
<div class="box-heading"><?php echo $attribute['attribute_name']; ?></div>
<div class="box-content">
<ul class="<?php echo $this->journal2->settings->get('filter_show_box') ? '' : 'hide-checkbox'; ?>">
<?php foreach ($attribute['values'] as $value) { ?>
<select>
<option><?php echo $value['name']; ?></option>
<?php foreach ($value['filter'] as $filter) { ?>
<?php if (in_array($filter['filter_id'], $filter_category)) { ?>
<option value="<?php echo $filter['filter_id']; ?>" id="filter<?php echo $filter['filter_id']; ?>" selected>
<?php echo $filter['name']; ?>
</option>
<?php } else { ?>
<option value="<?php echo $filter['filter_id']; ?>" id="filter<?php echo $filter['filter_id']; ?>">
<?php echo $filter['name']; ?>
</option>
<?php } ?>
<?php } ?>
</select>
<?php } ?>
</ul>
</div>
I am not doing everything good, because I can see only partial drop down now, and all is mixed up.
Any suggestions to edit my code? Thank you all in advance!
Put select tag outside foreach. This may help.
<select> <?php foreach ($attribute['values'] as $value) { ?>
<option><?php echo $value['name']; ?></option>
<?php foreach ($value['filter'] as $filter) { ?>
<?php if (in_array($filter['filter_id'], $filter_category)) { ?>
<option value="<?php echo $filter['filter_id']; ?>" id="filter<?php echo $filter['filter_id']; ?>" selected>
<?php echo $filter['name']; ?>
</option>
<?php } else { ?>
<option value="<?php echo $filter['filter_id']; ?>" id="filter<?php echo $filter['filter_id']; ?>">
<?php echo $filter['name']; ?>
</option>
<?php } ?>
<?php } ?>
<?php } ?>
</select>
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>';?>
}
I have a drop down box that shows the weight of the item and how much extra the heavier items cost. I also have javascript that updates the price on the page based on the value selected in the dropdown. Since the javascript updates the price shown on the page, I would like to remove the additional price shown next to the option choices.
the code is:
<?php if ($options) { ?>
<?php foreach ($options as $option) { ?>
<?php if ($option['type'] == 'select') { ?>
<span id="option-<?php echo $option['product_option_id']; ?>" class="option">
<select name="option[<?php echo $option['product_option_id']; ?>]">
<?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']; ?><span id="newPrice"><?php echo $option_value['price']; ?></span>)
<?php } ?>
</option>
<?php } ?>
</select>
</span>
I only want to show the product_option_id in the drop down, I don't want to show the added price for increases; I don't want this part of the code to be visable:
<?php if ($option_value['price']) { ?>
(<?php echo $option_value['price_prefix']; ?><span id="newPrice"><?php echo $option_value['price']; ?></span>)
<?php } ?>
however, I have some javascript that updates price based off the $option_value['price']. So I can't just erase it.
Is there a way to keep the output from echoing onto the screen, but still have javascript be able to find it?
Yes:
<?php if ($option_value['price']) { ?>
(<?php echo $option_value['price_prefix']; ?><span style="display:none" id="newPrice"><?php echo $option_value['price']; ?></span>)
<?php } ?>
Also you should consider not using an ID on that span, unless you are generating a unique id for each one, as it will cause you problems when you try to grab it with document.getElementById()
Using OpenCart as an ecommerce solution I'm trying to edit the cart page so that I can update option values in addition to quantity and have run into a bit of trouble.
My current code takes the correct option that's been chosen and puts it in a select box. Here's the code:
<?php foreach ($product['option'] as $option) { ?>
<div style="float: left; width: 100px;">
<select style=" text-align: left;" class="storeitems" name="option[<?php echo $option['option_id']; ?>]" selected="<?php echo $option['value']; ?>">
<option>
<?php echo $option['value']; ?>
</option>
</select>
</div>
<?php } ?>
Now, I need it to pull in the other options (as seen on the proudct page). Here is that code:
<select style="max-width: 145px;" class="storeitems" name="option[<?php echo $option['option_id']; ?>]" selected="<?php echo $option_value['name']; ?>">
<?php foreach ($option['option_value'] as $option_value) { ?>
<option value="<?php echo $option_value['option_value_id']; ?>"><?php echo $option_value['name']; ?>
</option>
<?php } ?>
</select>
In your second piece of code you have no product identification so opencart doesn't know what product to display options for.