Custom message in New Order Confirmation Shippin Method Magento CE - magento

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.

Related

Google Fit API - International users sync issue

I'm using the Google Fit API Rest
Here is the data I'm retrieving from Google Fit using the API:
2021-03-21 29989 Steps
2021-03-20 12 Steps
Here is the data the user exported from Google:
3/22/2021 16,480 Steps
3/21/2021 13,521 Steps
In both circumstances, the steps equal 30,001
The dates are clearly off by one day because of the time zone. The daily count is also off for the same reason, however, it added up to the same steps.
What general approach/strategy can I take to get the steps obtained from the API match those on Google Fit when I don't have a timezone?
My API currently loops through the database and syncs all user data, not distinguishing domestic vs international users.
Here is the code snippet used to get steps:
//***** Get steps
case DATATYPE_STEP_COUNT_DELTA:
if ($dataStreamId == 'derived:com.google.step_count.delta:com.google.android.gms:estimated_steps') {
$listDatasets = $dataSets->get("me", $dataStreamId, $startTime . '000000000' . '-' . $endTime . '000000000');
if ($debug == 1) PrintR($listDatasets,"DATATYPE_STEP_COUNT_DELTA");
$step_count = 0;
foreach ($listDatasets as $dataSet) {
if ($dataSet['startTimeNanos']) {
$sec = $dataSet['startTimeNanos'] / 1000000000;
$activity_date = date('Y-m-d', $sec);
$dataSetValues = $dataSet['value'];
if ($dataSetValues && is_array($dataSetValues)) {
foreach ($dataSetValues as $dataSetValue) {
if(!isset($stepsArr[$studentencodedid][$activity_date])) $stepsArr[$studentencodedid][$activity_date] = 0;
$stepsArr[$studentencodedid][$activity_date] += $dataSetValue['intVal'];
$step_count += $dataSetValue['intVal'];
}
}
}
}
}
break;
//***** End get steps

CT_FETCH error in PowerBuilder Program

I'm still learning PowerBuilder and trying to get familiar with it. I'm receiving the following error when I try to run a program against a specific document in my database:
ct_fetch(): user api layer: internal common library error: The bind of result set item 4 resulted in an overflow. ErrCode: 2.
What does this error mean? What is item 4? This is only when I run this program against a specific document in my database, any other document works fine. Please see code below:
string s_doc_nmbr, s_doc_type, s_pvds_doc_status, s_sql
long l_rtn, l_current_fl, l_apld_fl, l_obj_id
integer l_pvds_obj_id, i_count
IF cbx_1.checked = True THEN
SELECT dsk_obj.obj_usr_num,
dsk_obj.obj_type,
preaward_validation_doc_status.doc_status,
preaward_validation_doc_status.obj_id
INTO :s_doc_nmbr, :s_doc_type, :s_pvds_doc_status, :l_pvds_obj_id
FROM dbo.dsk_obj dsk_obj,
preaward_validation_doc_status
WHERE dsk_obj.obj_id = :gx_l_doc_obj_id
AND preaward_validation_doc_status.obj_id = dsk_obj.obj_id
using SQLCA;
l_rtn = sqlca.uf_sqlerrcheck("w_pdutl095_main", "ue_run_script", TRUE)
IF l_rtn = -1 THEN
RETURN -1
END IF
//check to see if document (via obj_id) exists in the preaward_validation_doc_status table.
SELECT count(*)
into :i_count
FROM preaward_validation_doc_status
where obj_id = :l_pvds_obj_id
USING SQLCA;
IF i_count = 0 THEN
//document doesn't exist
// messagebox("Update Preaward Validation Doc Status", + gx_s_doc_nmbr + ' does not exist in the Preaward Validation Document Status table.', Stopsign!)
//MC - 070815-0030-MC Updating code to insert row into preaward_validation_doc_status if row doesn't already exist
// s_sql = "insert into preaward_validation_doc_status(obj_id, doc_status) values (:gx_l_doc_obj_id, 'SUCCESS') "
INSERT INTO preaward_validation_doc_status(obj_id, doc_status)
VALUES (:gx_l_doc_obj_id, 'SUCCESS')
USING SQLCA;
IF sqlca.sqldbcode <> 0 then
messagebox('SQL ERROR Message',string(sqlca.sqldbcode)+'-'+sqlca.sqlerrtext)
return -1
end if
MessageBox("PreAward Validation ", 'Document number ' + gx_s_doc_nmbr + ' has been inserted and marked as SUCCESS for PreAward Validation.')
return 1
Else
//Update document status in the preaward_validation_doc_status table to SUCCESS
Update preaward_validation_doc_status
Set doc_status = 'SUCCESS'
where obj_id = :l_pvds_obj_id
USING SQLCA;
IF sqlca.sqldbcode <> 0 then
messagebox('SQL ERROR Message',string(sqlca.sqldbcode)+'-'+sqlca.sqlerrtext)
return -1
end if
MessageBox("PreAward Validation ", 'Document number '+ gx_s_doc_nmbr + ' has been marked as SUCCESS for PreAward Validation.')
End IF
update crt_script
set alt_1 = 'Acknowledged' where
ticket_nmbr = :gx_s_ticket_nmbr and
alt_2 = 'Running' and
doc_nmbr = :gx_s_doc_nmbr
USING SQLCA;
Return 1
ElseIF cbx_1.checked = False THEN
messagebox("Update Preaward Validation Doc Status", 'The acknowledgment checkbox must be selected for the script to run successfully. The script will now exit. Please relaunch the script and try again . ', Stopsign!)
Return -1
End IF
Save yourself a ton of headaches and use datawindows... You'd reduce that entire script to about 10 lines of code.
Paul Horan gave you good advice. This would be simple using DataWindows or DataStores. Terry Voth is on the right track for your problem.
In your code, Variable l_pvds_obj_id needs to be the same type as gx_l_doc_obj_id because if you get a result, it will always be equal to it. From the apparent naming scheme it was intended to be long. This is the kind of stuff we look for in peer reviews.
A few other things:
Most of the time you want SQLCode not SQLDbCode but you didn't say what database you're using.
After you UPDATE crt_script you need to check the result.
I don't see COMMIT or ROLLBACK. Autocommit isn't suitable when you need to update multiple tables.
You aren't using most of the values from the first SELECT. Perhaps you've simplified your code for posting or troubleshooting.

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

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.

Show backorder status on magento frontend

I need to show on the product page (frontend) that the current item is for backorder ONLY and is not in stock.
I have at the moment those in stock showing qty of what is available and those products on backorder doesn't show anything.
Does anyone know a code I can put in the view.phtml file that will ONLY show a message on those products set as backorder?
Thanks!
Simon.
To do this make sure you have enabled backorders from inventory tab.
If you are on product page then first of all retrieve product qty.
<?php
$inventory = Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product);
if( (int)$inventory->getQty() == 0 && $inventory->getBackorders() )
{
// No Backorders => getBackorders() = 0
// Allow Qty Below 0 => getBackorders() = 1
// Allow Qty Below 0 and Notify Customer => getBackorders() = 2
echo "display your backordedr message";
}
?>
You can also put this code in
app\design\frontend\base\default\template\catalog\product\view\type\default.phtml file where availability message of product come from.
Here is the code that you need to add in view.phtml. This will show the backorder message:
$inventory = Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product);
$inv_qty = (int)$inventory->getQty();
if($inventory->getBackorders() >= 0 && $inv_qty == 0)
{
echo "Your backorder message goes here";
}

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