Magento - Let the user choose between exlude tax of include tax - magento

I have a product with multiple options.
The user chooses how much he wants to pay for the product.
First I have created a dropdown box with the values €5,- €10,- etc.
The product price i have put to €0.
When I choose 10 euros, the product changes to 10 euros - that's good.
Now I want a checkbox where users can choose between Exclude Tax and Include Tax, so if I choose excluding tax the product will be inserted in the shopping cart as €10,00 witch is ok (excluding tax).
But when I choose Including tax the product needs to be inserted in the shopping cart as 10 /1.21 = €8,26 (excluding tax).
How can I make this possible?
EDIT:
I have the following code:
$event = $observer->getEvent();
$quote_item = $event->getQuoteItem();
if (is_array($quote_item->getOptions())) {
foreach ($quote_item->getOptions() as $optionValue) {
echo ???? . ' --> ' . $optionValue->getValue() . '<br />';
}
}
This will give me the values from the options.
But how do I get the real option_id? I get the option_type_id now.

If you look to below page
app/design/frontend/default/default/template/catalog/product/price.phtml
you will find below code
<?php if ($_weeeTaxAmount && $_weeeHelper->typeOfDisplay($_product, 0)): // including ?>
<span class="price-excluding-tax">
<span class="label"><?php echo $_taxHelper->__('Excl. Tax:') ?></span>
<span class="price" id="price-excluding-tax-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>">
<?php echo $_coreHelper->currency($_price+$_weeeTaxAmount,true,false) ?>
</span>
</span>
<span class="price-including-tax">
<span class="label"><?php echo $_taxHelper->__('Incl. Tax:') ?></span>
<span class="price" id="price-including-tax-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>">
<?php echo $_coreHelper->currency($_finalPriceInclTax+$_weeeTaxAmount,true,false) ?>
</span>
</span>
<?php elseif ($_weeeTaxAmount && $_weeeHelper->typeOfDisplay($_product, 1)): // incl. + weee ?>
<span class="price-excluding-tax">
<span class="label"><?php echo $_taxHelper->__('Excl. Tax:') ?></span>
<span class="price" id="price-excluding-tax-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>">
<?php echo $_coreHelper->currency($_price+$_weeeTaxAmount,true,false) ?>
</span>
</span>
to implement you can refer
Changing the price in quote while adding product to cart: magento

Related

Disable add to cart if in quantity box is 0

I'm looking for solution for my problem. I have category list with add to cart button and quantity box. I need to disable add to cart when is in quantity box 0 and allow it when is 1 and more.
I need default value 0.
Now, when I click to add to cart button is added one product to the cart.
This problem is just in category list, not on product page.
My code from /app/design/frontend/theme/theme/template/catalog/product/list.phtml
<?php if ( !($product->getTypeInstance(true)->hasOptions($product)/*$_product->getData('has_options')*/ || $product->isGrouped()) ) : ?>
<div class="qty-holder">
<input type="text" name="qty" id="qty_<?php echo $_product->getId(); ?>" maxlength="12" value="<?php echo $product->getProductDefaultQty() * 1 ?>" title="<?php echo $this->__('Qty') ?>" class="input-text qty" />
<div class="qty-changer">
<i class="icon-up-dir"></i>
<i class="icon-down-dir"></i>
</div>
</div>
</form>
<?php $_productid == $_product->getId(); ?>
</i><span> <?php echo $this->__('Add to Cart') ?></span>
<?php else : ?>
<i class="icon-cart"></i><span> <?php echo $this->__('Add to Cart') ?></span>
<a href='<?php echo $this->getUrl('ajaxcart/index/options',array('product_id'=>$_product->getId()));?>' class='fancybox' id='fancybox<?php echo $_product->getId()?>' style='display:none'>Options</a>
<?php endif;?>
Any ideas?
Thanks!
Maybe something like this (javascript):
jQuery('.addtocart').each(function() {
var $self = jQuery(this),
oldOnClick = $self.attr('onclick'),
$product = $self.closest('.item');
$self.attr('data-onclick', oldOnClick).removeAttr('onclick');
$self.off('click').on('click', function() {
if($product.find('.input-text.qty').val() < 1)
return false;
else
eval(jQuery(this).data('onclick'));
});
});
When user clicks on 'add to cart', check if the quantity value is >= 1.
Edit: fix some things..
Put this condition to disable addtocart and add disabled="disbled" in anchor tag of add to cart
if($product->getProductDefaultQty() * 1 == 0){
<a disabled = "disabled"></a>
}
else{
// your normal code here for add to cart
}

How to show configurable product stock status?

I have this phtml file which shows stock status:
<?php $_product = $this->getProduct() ?>
<?php $productQty = (int) Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getQty(); ?>
<?php if ($productQty > 100): ?>
<div class="catalog-stock over-stock">
<span class="qry-text"><?php echo $this->__('In stock:'); ?></span>
<span class="qry-count">100+</span>
</div>
<?php elseif ($productQty > 0 && $productQty <= 100): ?>
<div class="catalog-stock normal-stock">
<span class="qry-text"><?php echo $this->__('In stock:'); ?></span>
<span class="qry-count"><?php echo $productQty; ?></span>
</div>
<?php elseif ($deliveryDate = $_product->getStockDeliveryDate()): ?>
<div class="catalog-stock no-stock">
<span class="qry-text"><?php echo $this->__('Expected'); ?></span>
<span class="qry-count"><?php echo $deliveryDate; ?></span>
</div>
<?php elseif ($_product->getTypeId() != 'configurable' && $_product->getTypeId() != 'grouped' && $_product->getTypeId() != 'bundle'): ?>
<div class="catalog-stock no-stock">
<span class="qry-text"><?php echo $this->__('Expected'); ?></span>
<span class="qry-count"><?php echo $this->__('n/a'); ?></span>
</div>
<?php endif; ?>
I call it with this line <?php echo $this->getChildHtml('product_type_data') ?> from product/view/view.phtml
When used with simple product it works perfectly, but how to do same thing with configurable product?
What I want is to change stock status depending on what configurations is selected.
One solution is to check if product is configurable and then display all values at same time and hide with css. But if I do this I have problem - how to know which product is selected and show it's stock status?
I guess best option would be to do this with ajax, but I spent hours trying to do that and didn't succeed.

Display delivery time in magento

I want to display delivery time of products along with IN STOCK on my magento(1.7) based shopping cart.
For eg: "Delivered in 2-3 business days."
Is there any such option available in Magento community version?
One way that you can implement this is to add a new attribute to the product with all the different delivery options available.
You can then populate this and use the data to update the front end store. Emails etc.
This will be working for regular products.
<?php if ($qtyStock = (int)Mage::getModel('cataloginventory/stock_item')->loadByProduct($product)->getQty()>0):{?>
<p class="availability in-stock">
<span class="label"><?php echo $this->helper('catalog')->__('Availability:') ?></span>
<span class="value"><?php echo $this->helper('catalog')->__('In stock') ?></span>
<span class="value"><p>Delivery Time:</p>
<div id="delivery_time"><p>Delivered in 2-3 business days.</p></div></span>
</p>
<?php } else: { ?>
<p class="availability out-of-stock">
<span class="label"><?php echo $this->helper('catalog')->__('Availability:') ?></span>
<span class="value"><?php echo $this->helper('catalog')->__('Out of stock') ?></span>
</p>
<?php } endif; ?>

Jooma K2 show user description in comments

I really need help this time - Joomla 2.5 and latest K2.
I'm using the default K2 comment system and I want to show the "Description" field for every commenter on that page.
So far I have this code:
$thisUserdata =& JFactory::getUser($comment->userID);
echo $thisUserdata->profile->description;
But this shows the description for the author of the page only.
If I log in with another account, it'll also show my own Description as long as I'm logged in.
All the coding I'm doing is in /components/com_k2/templates/default/item.php
The whole code for comments looks like this:
<?php if($this->item->numOfComments>0 && $this->item->params->get('itemComments') && ($this->item->params->get('comments') == '1' || ($this->item->params->get('comments') == '2'))): ?>
<!-- Item user comments -->
<ul>
<?php foreach ($this->item->comments as $key=>$comment): ?>
<li class="<?php echo ($key%2) ? "odd" : "even"; echo (!$this->item->created_by_alias && $comment->userID==$this->item->created_by) ? " author-comment" : ""; echo($comment->published) ? '':' unpublishedComment'; ?>">
<div class="avatar">
<?php if($comment->userImage): ?>
<a href="<?php echo JFilterOutput::cleanText($comment->userLink); ?>" target="_blank" rel="nofollow">
<img src="<?php echo $comment->userImage; ?>" alt="<?php echo JFilterOutput::cleanText($comment->userName); ?>" width="<?php echo $this->item->params->get('commenterImgWidth'); ?>" />
</a>
<?php endif; ?>
</div>
<div class="inner">
<div class="author">
<?php if(!empty($comment->userLink)): ?>
<a href="<?php echo $comment->userLink; ?>" title="View <?php echo $comment->userName; ?> profile" target="_blank" rel="nofollow">
<?php echo $comment->userName; ?>
</a>
<?php else: ?>
<a rel="nofollow"><?php echo $comment->userName; ?></a>
<?php endif; ?>
</div>
<div class="date">
 <?php echo JHTML::_('date', $comment->commentDate, JText::_('K2_DATE_FORMAT_COM_MARIO')); ?>
</div>
<p><?php echo $comment->commentText; ?>
<?php
// USER DESCRIPTION
$thisUserdata =& JFactory::getUser($comment->userID);
echo $thisUserdata->profile->description;
?>
</div>
</div>
</li>
<?php endforeach; ?>
</ul>
<div class="itemCommentsPagination">
<?php echo $this->pagination->getPagesLinks(); ?>
<div class="clr"></div>
</div>
<?php endif; ?>
<?php if($this->item->params->get('commentsFormPosition')=='below' && $this->item->params->get('itemComments') && !JRequest::getInt('print') && ($this->item->params->get('comments') == '1' || ($this->item->params->get('comments') == '2' && K2HelperPermissions::canAddComment($this->item->catid)))): ?>
<!-- Item comments form -->
<div class="itemCommentsForm">
<?php echo $this->loadTemplate('comments_form'); ?>
</div>
<?php endif; ?>
With Joomla 2.5 you can use that to get basic user information, but you want to use the following to get the "description" or "about me" content of the commenting user..
$commentUser = JUserHelper::getProfile($comment->userID);
print_r($commentUser);
$about_me = $commentUser->profile['aboutme'];
echo $about_me;
Here is the link as well, this might help if you would like to do other things with the JUserHelper..
http://api.joomla.org/Joomla-Platform/User/JUserHelper.html#getProfile
EDIT: Make sure the plugin "User - Profile" is enabled or this will not work.

Magento - Tax Excluded on Product Details Page but Included on Listing Page

My problem is that I don't have the same price in Product Details and Listing Page.
I want to have all over the website the prices Included Tax.
How Can I solve this problem probably of configuration in Magento backend.
Thanks a lot.
for Product List :
look at the following file
root/app/design/frontend/default/default/template/catalog/product/price.phtml
you will see the following code which you can change what you want :
<?php if ($_weeeTaxAmount && $_weeeHelper->typeOfDisplay($_product, 0)): // including ?>
<span class="price-excluding-tax">
<span class="label"><?php echo $_taxHelper->__('Excl. Tax:') ?></span>
<span class="price" id="price-excluding-tax-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>">
<?php echo $_coreHelper->currency($_price+$_weeeTaxAmount,true,false) ?>
</span>
</span>
<span class="price-including-tax">
<span class="label"><?php echo $_taxHelper->__('Incl. Tax:') ?></span>
<span class="price" id="price-including-tax-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>">
<?php echo $_coreHelper->currency($_finalPriceInclTax+$_weeeTaxAmount,true,false) ?>
</span>
</span>
<?php elseif ($_weeeTaxAmount && $_weeeHelper->typeOfDisplay($_product, 1)): // incl. + weee ?>
<span class="price-excluding-tax">
<span class="label"><?php echo $_taxHelper->__('Excl. Tax:') ?></span>
<span class="price" id="price-excluding-tax-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>">
<?php echo $_coreHelper->currency($_price+$_weeeTaxAmount,true,false) ?>
</span>
</span>

Resources