Magento: How to remove the price for bundled product options on the shopping cart page, checkout etc - magento

Please help me removing the price for bundled product options on the shopping cart page, checkout, etc. Here is a pic.
What do i need to do?

To remove this edit:
Mage_Bundle_Block_Checkout_Cart_Item_Renderer
Look for the _getBundleOptions() method and at around line 77 change it as follows
//$option['value'][] = $this->_getSelectionQty($bundleSelection->getSelectionId()).' x '. $this->htmlEscape($bundleSelection->getName()). ' ' .Mage::helper('core')->currency($this->_getSelectionFinalPrice($bundleSelection));
//New line
$option['value'][] = $this->_getSelectionQty($bundleSelection->getSelectionId()).' x '. $this->htmlEscape($bundleSelection->getName());
Then edit:
Mage_Bundle_Block_Sales_Order_Items_Renderer
Look for the getValueHtml() method at around line 115 change the code as follows
public function getValueHtml($item)
{
if ($attributes = $this->getSelectionAttributes($item)) {
//Old code
/*
return sprintf('%d', $attributes['qty']) . ' x ' .
$this->htmlEscape($item->getName()) .
" " . $this->getOrder()->formatPrice($attributes['price']);
*/
return sprintf('%d', $attributes['qty']) . ' x ' .
$this->htmlEscape($item->getName());
} else {
return $this->htmlEscape($item->getName());
}
}
The usual caveats about not editing core code and using local or module rewrites apply!
let me know if i can help you more.
OR Also you can hide with css like below
Assuming that you want to remove it from all items regardless of the price, then you could add this css
#shopping-cart-table dd span.price{
display:none;
}
If you only want to remove the price if it is zero,you can also do in this way
/app/design/frontend/default/{theme path}/template/checkout/cart/item/default.phtml (around line # 46)
Figure out where it is add the price and only append the price if it is greater than 0
or
Do a find a replace str_replace("$0.00", "", $_formatedOptionValue['value']) on the string that display that line (make sure to add the currency sign so that $10.00 dont get replace)

I found another way to do it. Hopefully it will help somebody.
1 - Go to /public_html/app/code/core/Mage/Bundle/Helper/Catalog/Product
2 - open the file Configuration.php
3 - from about line 119 till about 127 you will find this code:
foreach ($bundleSelections as $bundleSelection) {
$qty = $this->getSelectionQty($product, $bundleSelection->getSelectionId()) * 1;
if ($qty) {
$option['value'][] = $qty . ' x ' . $this->escapeHtml($bundleSelection->getName())
. ' ' . Mage::helper('core')->currency(
$this->getSelectionFinalPrice($item, $bundleSelection)
);
}
}
Change that with this code:
foreach ($bundleSelections as $bundleSelection) {
$qty = $this->getSelectionQty($product, $bundleSelection->getSelectionId()) * 1;
if ($qty) {
$option['value'][] = $this->escapeHtml($bundleSelection->getName());
}
}
One caution note, be careful about editing the core file. You can also use local or module rewrites.

Related

Magento 2 - wrong number of digits between separators for prices in Indian Rupees

I am using Magento 2.2.3. my default currency is INR, but it shows in the wrong format:
But it should be ₹77,65,000.00. How do we correct price format? Currently its wrong... like USD.
You can set the currency format by following code.
<?php
$objectManager = \Magento\Framework\App\ObjectManager::getInstance(); // Instance of Object Manager
$priceHelper = $objectManager->create('Magento\Framework\Pricing\Helper\Data'); // Instance of Pricing Helper
$price = 1000; //Your Price
$formattedPrice = $priceHelper->currency($price, true, false);
?>
File path: vendor/magento/zendframework1/library/Zend/Locale/Data/en.xml
On line number 3353, under section currencyFormat and type = "standard", change the pattern from <pattern>¤#,##0.00</pattern> to <pattern>¤ #,##,##0.00</pattern>
Still, on PDP page and cart page summary the price format does not change because the prize format is coming from the JS in which Magento using a RegExp function for only US price format.
For that, please change the code in the below file.
File path: vendor/magento/module-catalog/view/base/web/js/price-utils.js (First extend this file in your theme directory and do the respected changes)
Under the function formatPrice below this line comment all the line in the respective function.
i = parseInt(
amount = Number(Math.round(Math.abs(+amount || 0) + 'e+' + precision) + ('e-' + precision)),
10
) + '';
And add this set of code below the above line.
var x=i;
x=x.toString();
var afterPoint = '';
if(x.indexOf('.') > 0)
afterPoint = x.substring(x.indexOf('.'),x.length);
x = Math.floor(x);
x=x.toString();
var lastThree = x.substring(x.length-3);
var otherNumbers = x.substring(0,x.length-3);
if(otherNumbers != '')
lastThree = ',' + lastThree;
var response = otherNumbers.replace(/\B(?=(\d{2})+(?!\d))/g, ",") + lastThree + afterPoint;
return pattern.replace('%s', response);
deploy and `rm -rf var/cache/*
And then you're done. For Example: A price previously displayed like 453,453, will now display in the Indian manner like 4,53,453.

Custom message in New Order Confirmation Shippin Method Magento CE

I am trying to setup a custom message in the New Order Confirmation email for "Shipping Method" when someone selects the shipping method "Store Pickup" at checkout. In the DB the method name is called flatrate2. Here is the snippet that I was attempting to edit...
if ($method) {
foreach ($address->getAllShippingRates() as $rate) {
if ($rate->getCode()==$method) {
$amountPrice = $address->getQuote()->getStore()->convertPrice($rate->getPrice(), false);
$this->_setAmount($amountPrice);
$this->_setBaseAmount($rate->getPrice());
if (!$method=='flatrate2'){
$shippingDescription = $rate->getCarrierTitle() . ' - ' . $rate->getMethodTitle();}
else{ $shippingDescription = 'Your merchandise will be ready for pickup 45 minutes after completing your order.<br/>Store Pickup is available Mon – Friday 11:30 AM – 4:30 PM';}
$address->setShippingDescription(trim($shippingDescription, ' -'));
break;
}
}
}
No matter which shipping method is selected I only get the message 'Your merchandise will be ready for pickup 45 minutes after completing your order.Store Pickup is available Mon – Friday 11:30 AM – 4:30 PM'
Any help would be appreciated. Thank you!
within that code do this:
if ($method=='your specific shipping ')
{ $shippingDescription = $rate->getCarrierTitle() . ' - ' . $rate->getMethodTitle();}
elseif($method=='your other shipping method ')
{ $shippingDescription = $rate->getCarrierTitle() . ' - ' . $rate->getMethodTitle();}
and so on.
To summarize all times your code condition if (!$method=='flatrate2'){ is failing resulting in else condition getting executed.
I approached this a different way. In my email template I added.
{{block type='core/template' area='frontend' template='cms/orderemail.phtml' order=$order}}
Then in my orderemail.phtml I placed this snippet in it...
$pShipping = $this->getData('order')->getShippingDescription();
if ($pShipping == 'Store Pickup - Store Pickup') {
This solved my problem.

Joomla 2.5 not limit one vote per IP address

Joomla 2.5 by default limits the number of how many votes a user can do. This is limited by IP address.
Is there any simple way to allow multiple votes per IP Address?
I am using the CORE Voting.
Actually, Joomla! 2.5 only stores the last voter's IP address per item.
If another vote comes from a different IP address, the user with the original IP address can vote again.
This behavior is defined in /components/com_content/models/article.php, circa line 308.
if ($userIP != ($rating->lastip))
{
$db->setQuery(
'UPDATE #__content_rating' .
' SET rating_count = rating_count + 1, rating_sum = rating_sum + '.(int) $rate.', lastip = '.$db->Quote($userIP) .
' WHERE content_id = '.(int) $pk
);
if (!$db->query()) {
$this->setError($db->getErrorMsg());
return false;
}
} else {
return false;
}
Changing it involves core file hacking.
One thing that you can do make the test in the if clause always return true, so one possibility is to comment first line and replace it with
if (true)//$userIP != ($rating->lastip))
{
$db->setQuery(
'UPDATE #__content_rating' .
' SET rating_count = rating_count + 1, rating_sum = rating_sum + '.(int) $rate.', lastip = '.$db->Quote($userIP) .
' WHERE content_id = '.(int) $pk
);
if (!$db->query()) {
$this->setError($db->getErrorMsg());
return false;
}
} else {
return false;
}
I don't find the original core solution that great, and it is not customizable, either.

K2 extra fields access in BT Content slider

I'm trying to access the contents of a K2 extra field inside the BT content slider plugin. If I do
print_r($row->extra_fields);
I get
[{"id":"16","value":"http:\/\/www.youblisher.com\/p\/611670-Test-Intro-to-R\/"}]
I need to access the value, but I've tried everything I could think of with no luck.
Tests I've done (also tried print_r for everything just in case):
echo $row->extra_fields[0]
echo $row->extra_fields[0]->value
echo $row->extra_fields->value
echo $row->extra_fields["value"]
Decode your string into a json object first before trying to access value.
<?php
$json = json_decode('[{"id":"16","value":"http:\/\/www.youblisher.com\/p\/611670-Test- Intro-to-R\/"}]');
print_r($json[0]->value);
?>
OK, I got it working the way I wanted it to.
I wanted to replace intro / full text with an extrafield that I called 'Accroche' . This extrafield has an ID of 132 (useful to know the ID that will be used in code below).
We will be editing 2 files :
/modules/mod_bt_contentslider/classes/content.php
and
/modules/mod_bt_contentslider/classes/k2.php
First thing to do is get the extrafield info from database :
in /modules/mod_bt_contentslider/classes/content.php (around line 77) I added [b]a.extra_fields,[/b] as follows
$model->setState('list.select', 'a.urls, a.images, a.fulltext, a.id, a.title, a.alias, a.introtext, a.extra_fields, a.state, a.catid, a.created, a.created_by, a.created_by_alias,' . ' a.modified, a.modified_by,a.publish_up, a.publish_down, a.attribs, a.metadata, a.metakey, a.metadesc, a.access,' . ' a.hits, a.featured,' . ' LENGTH(a.fulltext) AS readmore');
Save file & close
Now lets get to /modules/mod_bt_contentslider/classes/k2.php (around line 234),
Replace this original code
// cut introtext
if ($limitDescriptionBy == 'word') {
$item->description = self::substrword($item->introtext, $maxDesciption, $replacer, $isStrips, $stringtags);
$item->description = self::substring($item->introtext, $maxDesciption, $replacer, $isStrips, $stringtags);
}
$item->categoryLink = urldecode(JRoute::_(K2HelperRoute::getCategoryRoute($item->catid . ':' . urlencode($item->categoryalias))));
// get author name & link
With this code that I've commented to make things understandable for noobs like me ;)
// REPLACE intro/full text With extra-field info
$extras = json_decode($item->extra_fields); // JSON Array we'll call extras (note final 's' : not to confuse with below variable)
foreach ($extras as $key=>$extraField): //Get values from array
if($extraField->value != ''): //If not empty
if($extraField->id == '132'): // This is ID value for extrafield I want to show --- Search your K2 extrafield's id in Joomla backoffice ->K2 ->extrafields ---
if($extraField->value != ''): // If there's content in the extrafield of that ID
$extra = $extraField->value; //Give $extra that value so we can hand it down below
endif;
endif;
endif;
endforeach;
// cut introtext
if ($limitDescriptionBy == 'word') {
// $item->description = self::substrword($item->introtext, $maxDesciption, $replacer, $isStrips, $stringtags);
$item->description = self::substrword($extra, $maxDesciption, $replacer, $isStrips, $stringtags);
} else {
// $item->description = self::substring($item->introtext, $maxDesciption, $replacer, $isStrips, $stringtags);
$item->description = self::substring($extra, $maxDesciption, $replacer, $isStrips, $stringtags) ;
}
$item->categoryLink = urldecode(JRoute::_(K2HelperRoute::getCategoryRoute($item->catid . ':' . urlencode($item->categoryalias))));
// get author name & link
As you can see, I've commented out the intro texts as I don't want them. You can modify that if you want both introtext AND extrafield.
I'd have never figured this out without the JSON tip given above. Thanx to all :)
Hope this helps.
Cheers !

Magento save order total in checkout page

We have a system like gift cards balance usage in the checkout page.While customers on the checkout page customers can use their Gift card balance amount to buy products.
So i have added a a tab before payment tab in which customers have option to enter the amount o use from their gift card balance amount so when they say proceed am getting the entered value in custom Onepage controller and pass it to Onepage.php(Model class) to reduce the total amount.
This is what am doing on the model class.
public function saveCustomDiscount($discount=0)
{
$this->getQuote()->setGrandTotal($this->getQuote()->getGrandTotal() - $discount);
$this->getQuote()->setBaseGrandTotal($this->getQuote()->getBaseGrandTotal() - $discount);
$this->getQuote()->save();
//$this->getQuote()->collectTotals()->save();
$order = $this->getQuote()->getData();
Zend_Debug::dump($order);
return array();
}
And am calling this function from the controller Action function were am getting the user input.
Here what ever am passing as discount the total amount and base total is not reducing. Its same as original.
Note :
Before custom order save.
array(51) {
---------------
["grand_total"] => string(8) "243.7200"
["base_grand_total"] => string(8) "243.7200"
-----------------
}
After custom order save.
array(51) {
---------------
["grand_total"] => float(223.72)
["base_grand_total"] => float(223.72)
-----------------
}
The data type is changed from string to float when am doing debug. What i have to do, to reduce the order total from the custom discount. Please help me.
Thanks
Did you set the discountCode?
i.e. $quote->setCouponCode(strlen($couponCode) ? $couponCode : '')
->collectTotals()
->save();
Later on, in the Quote, did you apply the discount?
i.e. $order->setDiscountAmount(Mage::getSingleton('checkout/session')->getQuote()->getSubtotalWithDiscount() - Mage::getSingleton('checkout/session')->getQuote()->getSubtotal());
$order->setShippingAmount(Mage::getSingleton('checkout/session')->getQuote()->getShippingAddress()->getShippingAmount());
$order->setSubtotalWithDiscount(Mage::getSingleton('checkout/session')->getQuote()->getSubtotalWithDiscount());
$order->setGrandTotal(Mage::getSingleton('checkout/session')->getQuote()->getGrandTotal());
etc.
EDIT:
I've worked with a team to do a Wordpress / Magento hybrid and it's definitely left some learning lessons on me. Magento was used as a purely transactional engine and we had to do this entire checkout process by hand (including creating a custom WP plugin to handle each step in the cart).
Log this out at the end so we can see what you have (possibly put this in your edited question):
Mage::log("checkoutprocess: getSubtotal: " . $order->getSubtotal());
Mage::log("checkoutprocess: getTaxAmount: " . $order->getTaxAmount());
Mage::log("checkoutprocess: getDiscountAmount: " . $order->getDiscountAmount());
Mage::log("checkoutprocess: getShippingAmount: " . $order->getShippingAmount());
Mage::log("checkoutprocess: getGrandTotal: " . $order->getGrandTotal());
Mage::log("checkoutprocess: getBaseSubtotal: " . $order->getBaseSubtotal());
Mage::log("checkoutprocess: getBaseDiscountAmount: " . $order->getBaseDiscountAmount());
Mage::log("checkoutprocess: getSubtotalWithDiscount: " . $order->getSubtotalWithDiscount());
Mage::log("checkoutprocess: getBaseGrandTotal: " . $order->getBaseGrandTotal());

Resources