Magento update product price - magento

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)

Related

How to hide proceed checkout button until cart price less then hundred and customer group is not retailer in magento?

I want to hide proceed checkout button until cart price is less then 100 and customer group is "retailer" and if price greater then 100 and customer group is "Retailer" then proceed checkout button show. How to achieve this functionality ? Help Me.
In your theme, edit the template file
checkout/onepage/link.phtml
there is code
<?php if ($this->isPossibleOnepageCheckout()):?>
<button type="button" title="<?php echo $this->__('Proceed to Checkout') ?>" class="button btn-proceed-checkout btn-checkout<?php if ($this->isDisabled()):?> no-checkout<?php endif; ?>"<?php if ($this->isDisabled()):?> disabled="disabled"<?php endif; ?> onclick="window.location='<?php echo $this->getCheckoutUrl() ?>';"><span><span><?php echo $this->__('Proceed to Checkout') ?></span></span></button>
<?php endif?>
You will find this function isPossibleOnepageCheckout() in
Mage/Checkout/Block/Onepage/Link.php
You can extend this class and add your custom logic by which you can hide the checkout button.
Also in /Mage/Checkout/controllers/OnepageController.php
in indexAction()
write your condition so that user is redirected to cart page if condition is not fulfilled

attribute value added cart checkout and order page

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.

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?

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