attribute value added cart checkout and order page - magento

I am using Magento Version 1.7.0.2
I have added available_color for different product color(newly added attributes) check box in product detail page.using below code
app\design\frontend\default{mytempalte}\template\catalog\product\view.phtml
<?php
$_product->getResource()->getAttribute('available_colors')->getFrontend()->getValue($_product);
$color = $_product->getAttributeText('available_colors');
?>
<h2>Item Color</h2>
<?php foreach ($color as $value): ?>
<label class="span4" style="margin-left:0px;">
<input class="pro_color_<?php echo $value; ?>" name="<?php echo $value; ?>" value="<?php echo $value; ?>" type="checkbox">
<?php echo $value; ?>
</label>
<?php endforeach; ?>
customer can able to select the multiple color .After select the product color I need to show multiple color value in cart and checkout and order page.
how to pass the color value from product detail to other page?.
Thanks

I think you should use the Custom Options feature for this instead of using an attribute.
Here is a nice screencast about custom options.
You just have to create a custom option with type checkbox and use as values you colors. The downside of this is that if you want the options for more products, you will have to manually add the option for all. Or you can search for an extension that allows one custom option for multiple products.
After adding the options, you don't have to do anything. They will be added as options to the cart.

Related

Magento update product price

I am trying to customize the magento associated product dropdown menu in frontend.
So far it's working good, But i need somehow to be able to update the price when a user has clicked the radio button. I guess i need to use some jquery stuff? The price is stored in the radio value. Any suggestions? :)
The code i'm currently working with is:
<?php
if($_product->getTypeId() == "configurable"):
$conf = Mage::getModel('catalog/product_type_configurable')->setProduct($_product);
$simple_collection = $conf->getUsedProductCollection()->addAttributeToSelect('*')->addFilterByRequiredOptions();
foreach($simple_collection as $simple_product){ ?>
<input type="radio" id="attribute135" name="attribute135" value="<?php echo strip_tags(Mage::helper('core')->currency($simple_product->getPrice())) ?>" /> <?php echo $simple_product->getName();
}
endif;
?>
I ended using:
$_product->setPrice(new price value here)

New added attribute value pass from product detail page to cart, checkout and order

I have added new attributes to the product with multiselect option in admin.
I get the values for the selected attributes from checkbox in view.phtml (product page).
Now, I want to pass these selected checkbox values to the cart page, checkout page and order page. But I am struggling to find an easy way to do so.
Any help is greatly appreciated.
here available_colors is my attribute name
<div class="available_color span10" style="margin:10px 0;">
<?php
$_product->getResource()->getAttribute('available_colors')->getFrontend()->getValue($_product);
$color = $_product->getAttributeText('available_colors');
//print_r ($color);
?>
<h2>Item Color</h2>
<?php foreach ($color as $value): ?>
<label class="span4" style="margin-left:0px;">
<input class="pro_color_<?php echo $value; ?>" name="<?php echo $value; ?>" value="<?php echo $value; ?>" type="checkbox">
<?php echo $value; ?>
</label>
<?php endforeach; ?>
</div>
it display in product page but problem is that
when I add to product add-to-cart attribute value not pass and display in cart, checkout page.
You could use Product Custom Options to acheive this.Select the product to which you want to add custom options .You can find a tab named Custom Options.You can add the options there.
If I understand what you want, you need to store your product attribute through the quote and finally to the order.
You'll need to :
create new attribute (column) on quote and order
fill these new attributes with the user selection when adding product to quote
display it on the checkout (quote attribute value) and on the order page (order attribute value)
For the attribute creation check this link : http://www.atwix.com/magento/custom-product-attribute-quote-order-item/ .
For the display of your attribute on your pages, you just have to adapt your code to check the quote_item or order_item values.

Magento Custom options in grouped products page. Price not reflecting on selection

I had a customized grouped product page in a magento store. I can able to put custom option values in that grouped product page by simply editing grouped.phtml file with this code.
foreach($product->getOptions() as $o):
$values = $o->getValues();
I can able to publish custom option title and its value using this code;
echo $v->getData('title');
echo ('+').$v->getData('price');
But the problem is i can't able to reflect the price on custom option selection.
When i go through the view.phtml file, i can able to see that a function is calling on custom option fields so that price is reflecting.
So i rewrite my custom options select box code like this
<select name="sel_<?php echo $_item->getId()?>" id="sel_<?php echo $_item->getId()?>" class=" product-custom-option" title="" onchange="opConfig.reloadPrice()">
<option value="">-- Please Select --</option>
<?php foreach ($values as $v):?>
<option value="<?php echo $v->getData('title');echo ('+').$v->getData('price');?>">
<?php echo $v->getData('title');echo ('+').$v->getData('price');?>
</option>
<?php endforeach;?>
</select>
Here I had called an onchange function opConfig.reloadPrice() in select box. But still price is not changing. What will be the possible issues?

magento: how to show custom attributes from general tab in front page automatically

when we upload one product, there is a default attribute set "Default", and in the general tab, there are many default attributes like below image:
well, i added one more custom attribute named "size", when i drag 'size' to general tab on the left, that mean the product has one more attribute. if i want to show the size attribute in the product view page of front end page, i have to put the code: "$_product->getAttributeText('size')", if i added lots of custom attributes, i have to put lots of codes manually. so, my question is how i can show all custom attributes automatically instead of adding one by one manually ?
This is allready done by magento.
Mark your attributes as vissible in frontend and thats it.
Have a look at the template attributes.phtml in path app/design/frontend/yourtheme/default/template/catalog/product/view
<?php if($_additional = $this->getAdditionalData()): ?>
<!--h2><?php echo $this->__('Additional Information') ?></h2-->
<div class="data-table accordion" id="product-attribute-specs-table">
<?php foreach ($_additional as $_data): ?>
<?php $_attribute = $_product->getResource()->getAttribute($_data['code']);
if (!is_null($_product->getData($_attribute->getAttributeCode())) && ((string)$_attribute->getFrontend()->getValue($_product) != '')) { ?>
<div class="clearer <?php echo $this->htmlEscape($this->__($_data['label'])) ?>">
<div class="trigger"><?php echo $this->htmlEscape($this->__($_data['label'])) ?></div>
<div class="triggerContent" style="display: none;"><span><?php echo $_helper->productAttribute($_product, $_data['value'], $_data['code']) ?></span></div>
</div>
<?php } ?>
</div>
<script type="text/javascript">decorateTable('product-attribute-specs-table')</script>
You need to copy the default file from /app/design/frontend/base/default/template/catalog/product/view to your theme directory
/public_html/app/design/frontend/default/yourtheme/template/catalog/product/view

Display only in stock options for configurable products on catalog pages in Magento

I've managed to add options to configurable products on my catalog pages using the code found here: http://www.magentocommerce.com/boards/viewthread/21039/P45/#t167724. What I'd like to do now is only show the options that are available according to the stock of the simple product that the option is coming from.
For example, if I have a t-shirt (configurable product) that has various colors (simple products) and my red color is out of stock, red wouldn't be shown as an option when the configurable product is displayed.
What's the best way to do this?
Update:
For the sake of clarity, here is the relevant block of code from the link I posted.
<?php if($product->getTypeId() == "configurable"): ?>
<?php $attValConfig = $product->getTypeInstance()->getConfigurableAttributesAsArray(); ?>
<?php if(sizeof($attValConfig)): ?>
<?php foreach($attValConfig as $attValConfigSingle): ?>
<fieldset class="product-options" id="product-options-wrapper">
<label><?php echo $attValConfigSingle['label']; ?>:</label>
<select name="super_attribute[<?php echo $attValConfigSingle['attribute_id'] ?>]" id="attribute<?php echo $_product->getId() ?>" class="required-entry super-attribute-select">
<?php foreach($attValConfigSingle['values'] as $attValConfigSingleVal): ?>
<option value="<?php echo $attValConfigSingleVal['value_index'] ?>"><?php echo $attValConfigSingleVal['label'] ?></option>
<?php endforeach; ?>
</select>
</fieldset>
<?php endforeach; ?>
<?php endif; ?>
<?php endif; ?>
Since this code is simply getting all of the configurable options and displaying them, it doesn't check to see if the simple product that backs the configurable option is in stock. How do I do this?
I just wondering why we are checking the quantity for stock status why dont't we look on stock availability of simple products.
I have achieved to show out of stock on configurable product according to stock status.
Now you can make product "out stock" and "in stock" through stock availability attribute of simple product.
Try the following ( do what you want returning result ) :
$_productCollection = Mage::getModel('cataloginventory/stock_item')->getCollection()
->addIdFilter($productId) // this line is wrong, don't care this
->addFieldToFilter('qty', array('gteq' => 1));

Resources