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.
Related
Wordpress noob here, After searching for two days without any success!, i'm trying to display a difference color in the front end for each selected option from menu.
I used this code for creating menu inside users profile
<table class="form-table">
<tr>
<th><label for="dropdown">Job Stats</label></th>
<td>
<?php
//get dropdown saved value
$selected = get_the_author_meta( 'user_job_stats', $user->ID ); //there was an extra ) here that was not needed
?>
<select name="user_job_stats" id="user_job_stats">
<option class="available" value="available" <?php echo ($selected == "available")? 'selected="selected"' : '' ?>>Available</option>
<option class="busy" value="busy" <?php echo ($selected == "busy")? 'selected="selected"' : '' ?>>Busy</option>
</select>
<span class="description">Select Stats.</span>
</td>
</tr>
</table>
And i used this code for displaying them in the front end
<div class="job-stats">
<?php if (!empty(get_the_author_meta('user_job_stats', $curauth->ID))) { ?>
<dt><?php echo $curauth->user_job_stats; ?></dt>
<?php } ?>
</div>
What i'm trying to do is when users selected an option ex:Busy
I want to make the background color of the option " Busy" to be red IN FRONT END
And with option "Available" background color to be green IN FRONT END.
Any help please?
use CSS's pseudo class to style the relevant tags.
<style>
.available:checked { background: green; }
.busy:checked { background: red; }
</style>
<table class="form-table">
<tr>
<th><label for="dropdown">Job Stats</label></th>
<td>
<?php
//get dropdown saved value
$selected = get_the_author_meta( 'user_job_stats', $user->ID ); //there was an extra ) here that was not needed
?>
<select name="user_job_stats" id="user_job_stats">
<option class="available" value="available" <?php echo ($selected == "available")? 'selected="selected"' : '' ?>>Available</option>
<option class="busy" value="busy" <?php echo ($selected == "busy")? 'selected="selected"' : '' ?>>Busy</option>
</select>
<span class="description">Select Stats.</span>
</td>
</tr>
</table>
and for the front-end:
<style>
dt.available { background: green; }
dt.busy { background: red; }
</style>
<div class="job-stats">
<?php if (!empty(get_the_author_meta('user_job_stats', $curauth->ID))) { ?>
<dt class="<?php echo $curauth->user_job_stats ?>"><?php echo $curauth->user_job_stats; ?></dt>
<?php } ?>
</div>
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 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
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()
I am trying to extend product order
report and add one Attribute of
product brand and put into
grid.phtml.
when i select brand and click on
refresh button.
report will not display brand wise
searching what can i do?
product order report image link
Visit
http://imageshack.us/photo/my-images/405/productorder.jpg/
grid.phtm Code
<?php
$attributeInfo = Mage::getResourceModel('eav/entity_attribute_collection')
->setCodeFilter('brand')
->getFirstItem();
$attributeOptions = $attributeInfo->getSource()->getAllOptions(false);
?>
</div>
--><div class="f-left">
<?php echo $this->__('Brand') ?>:
<select name="brand" id="brand" style="width:6em;">
<?php foreach ($attributeOptions as $_value=>$_label): ?>
<option value="<?php echo $_value ?>" <?php if($this->getFilter('brand')==$_value): ?> selected<?php endif; ?>><?php echo $_label['label'] ?></option>
<?php //error_log("Lable".print_r($_label,TRUE));?>
<?php endforeach; ?>
</select>
</div>