Customize the current magento onestep checkout page - magento

Need help in customizing the existing onestep checkout page so that billing/customer info form will be included within the payment select section.
For Example,
If Customer has chosen Card as payment option then along with Card Details form fields it should also display billing information fields(First name, last name, email, country, zip, password, confirm password.) as well.
If customer has selected paypal as payment option then fields(Email, Password, Confirm password).
Basically, we are trying to reduce the number of steps and speed up the checkout.

Use the following
public function index( $category_id = null )
{
if (!$this->KnowledgeSolution->KnowledgeCategory->exists( $category_id ))
{
throw new NotFoundException(__('Invalid Knowledge Category'));
}
$KnowledgeCategory = $this->KnowledgeSolution->KnowledgeCategory->read(null,$category_id);
$this->set('KnowledgeCategory',$KnowledgeCategory);
$this->Paginator->settings['contain'] = array('Users','KnowledgeReply'=>array('Users') );
$this->set('KnowledgeSolutions', $this->Paginator->paginate());
$this->Paginator->settings = array('conditions' => array('Product .title LIKE' => 'a%'),'limit' => 10 );
$this->set(compact('data'));
}

Related

How to change the weight before sending to fedex magento?

In magento checkout page, after giving billing information and shipping information, i understand that these details are sending to fedex then the shipping rates are populating in chekout page, before sending theses details to fedex, i want to change the weight of the product, i Want to add additional weights for each products,
suppose user adding a product with weight of 2 pounds, i want to send
these weight to 2*5 = 10pounds, how can i do that in magento? please
help.
Not sure to understand what you want exactly but I'll give a try.
I think you can override Mage_Checkout_OnepageController::savePaymentAction method in your local pool and in your local method, dispatch your own new event 'save_payment_action_before' and pass your objects as parameters.
In your fedex module, create an observer, get your object and change the order weight before it's sent to fedex.
To create your custom event, check this post
Finally i find out that it is happening in the sales/quote/item.php file, there is a function called setProduct, here we need to add addititonal info while setting data.
public function setProduct($product)
{
$batchQty = Mage::getModel('catalog/product')->load($product->getId())->getBatchQty();
$roleId = Mage::getSingleton('customer/session')->getCustomerGroupId();
$userrole = Mage::getSingleton('customer/group')->load($roleId)->getData('customer_group_code');
$userrole = strtolower($userrole);
if ($this->getQuote()) {
$product->setStoreId($this->getQuote()->getStoreId());
$product->setCustomerGroupId($this->getQuote()->getCustomerGroupId());
}
if($userrole=="retailer" && $batchQty>0 ){
$this->setData('product', $product)
->setProductId($product->getId())
->setProductType($product->getTypeId())
->setSku($this->getProduct()->getSku())
->setName($product->getName())
->setWeight($this->getProduct()->getWeight()*$batchQty)
->setTaxClassId($product->getTaxClassId())
->setBaseCost($product->getCost())
->setIsRecurring($product->getIsRecurring());
} else {
$this->setData('product', $product)
->setProductId($product->getId())
->setProductType($product->getTypeId())
->setSku($this->getProduct()->getSku())
->setName($product->getName())
->setWeight($this->getProduct()->getWeight())
->setTaxClassId($product->getTaxClassId())
->setBaseCost($product->getCost())
->setIsRecurring($product->getIsRecurring());
}
if ($product->getStockItem()) {
$this->setIsQtyDecimal($product->getStockItem()->getIsQtyDecimal());
}
Mage::dispatchEvent('sales_quote_item_set_product', array(
'product' => $product,
'quote_item' => $this
));
return $this;
}

Cash on delivery payment method should visible only for some zip codes/pin codes in magento

we are using "Cash On Delivery" Payment method in magento 1.9.0 version
we support cash on delivery to only some zip/pin codes locations.
means we will accept cash only from some zip codes [means locations].
under "checkout" in "shipping address", customer will type his/her "zip code" .
using that zip code we have to validation.
means if we deliver the product to that zip code, than "COD" payment method should visible under "payment method"
otherwise "COD" should not visible.
if someone is unclear with above question , please refer following link :
How to restrict default COD in magento to certain zip codes only?
this is the question.
can anyone explain in detail about above solution....
or
also here in following link :
restrict default Cash on delivery for some zip/pin codes in magento 1.9.0
there is an option to enter list of zip codes that are restricted. but we need a solution for list of zip codes that allowed.
All you need is to edit the file /app/code/core/Mage/Payment/Model/Method/Cashondelivery.php
here you will get an answer :
public function isAvailable($quote = null)
{
if ($quote) {
// Here is the list of restricted Zip Codes
$restrictedZips = array(
'85001',
'87965'
);
$address = $quote->isVirtual() ? $quote->getBillingAddress() : $quote->getShippingAddress();
$customerZip = $address->getPostcode();
if (in_array($customerZip, $restrictedZips)) {
return false;
}
}
return parent::isAvailable($quote);
}
restrict default Cash on delivery for some zip/pin codes in magento 1.9.0
here is free extension for cashondelivery restrict based on zipcode
http://www.magentocommerce.com/magento-connect/cashondelivery-based-on-zipcode.html

Cancel Magento Orders With Expired Pre-Authorization

I have some orders in my Magento site that are older than 30 days so the authorize.net pre-auth has expired. When I go to cancel the orders, it tries to submit the pre-auth void but it fails because the original transaction no longer exists. Is there any way to manual override this void procedure and simply cancel an order in this state?
An easy way to do these Cancels as one-offs when you need to is to:
1) Grab the Auth.net transaction ID from the Order in Magento. It should display this in the Comments History at the bottom of the order.
2) Search the sales_payment_transaction table > txn_id field for that transaction ID
3) Once you locate the record in mySQL (helpful if you have phpMyAdmin), then just NULL out the txn_id for that record.
4) Back in Magento admin, you can now Cancel the order since it knows not to try and go back to Auth.net to cancel it.
** Alternatively you can easily find the record by the Order ID in the URL and find it that way in the same table. For instance:
https://www.yourdomain.com/store/index.php/backend/sales_order/view/order_id/6957/key/4c16ff2bfed4b496670be4747sdjhdfd6/
It's order_id: 6957 in the database.
Take a look #
/app/code/core/Mage/Paygate/Model/Authorizenet.php
Turn on debugging for your payment module to see the result of $result->getResponseCode() for an expired transaction. Once you figure out what the result (code/error code) are, you could create a new 'case' that mimic case self::RESPONSE_CODE_APPROVED:
Also take a look # $this->_isTransactionExpired($realAuthTransactionId) to see why it isn't catching your expired transaction.
protected function _voidCardTransaction($payment, $card)
{
$authTransactionId = $card->getLastTransId();
$authTransaction = $payment->getTransaction($authTransactionId);
$realAuthTransactionId = $authTransaction->getAdditionalInformation($this->_realTransactionIdKey);
$payment->setAnetTransType(self::REQUEST_TYPE_VOID);
$payment->setXTransId($realAuthTransactionId);
$request= $this->_buildRequest($payment);
$result = $this->_postRequest($request);
switch ($result->getResponseCode()) {
case self::RESPONSE_CODE_APPROVED:
if ($result->getResponseReasonCode() == self::RESPONSE_REASON_CODE_APPROVED) {
$voidTransactionId = $result->getTransactionId() . '-void';
$card->setLastTransId($voidTransactionId);
return $this->_addTransaction(
$payment,
$voidTransactionId,
Mage_Sales_Model_Order_Payment_Transaction::TYPE_VOID,
array(
'is_transaction_closed' => 1,
'should_close_parent_transaction' => 1,
'parent_transaction_id' => $authTransactionId
),
array($this->_realTransactionIdKey => $result->getTransactionId()),
Mage::helper('paygate')->getTransactionMessage(
$payment, self::REQUEST_TYPE_VOID, $result->getTransactionId(), $card
)
);
}
$exceptionMessage = $this->_wrapGatewayError($result->getResponseReasonText());
break;
case self::RESPONSE_CODE_DECLINED:
case self::RESPONSE_CODE_ERROR:
if ($result->getResponseReasonCode() == self::RESPONSE_REASON_CODE_NOT_FOUND
&& $this->_isTransactionExpired($realAuthTransactionId)
) {
.....
public function canVoid(Varien_Object $payment)
{
if ($this->_isGatewayActionsLocked($this->getInfoInstance())) {
return false;
}
return $this->_isPreauthorizeCapture($this->getInfoInstance());
}
For anyone still looking for how to cancel an order with an expired authorization.
Update the database record for sales_payment_transaction by changing the is_cloased value for the transaction to 1(Yes).
You will need the order id and the transaction id which you can both get from the url when viewing the transaction in your browser.
https//magento.com/admin/sales_transactions/view/txn_id/11111/order_id/55555/
$collection = Mage::getModel('sales/order_payment_transaction')
->getCollection()
->addAttributeToFilter('order_id', '11111')
->addAttributeToFilter('txn_id', '55555');
foreach ($collection as $col) {
if ($col->getId()){
$col->setIsClosed(1)->save();
}
}
You can also update the value through phpMyAdmin by opening the sales_payment_transaction and looking the for the row with order_id and txn_id for your order.
Once the is_closed value is set to 1, you should now be able to cancel the order since it tells the system the authorization is closed and not to try to void the authorization which has already expired on authorize dot net

Setting Order Status and adding custom carriers in Magento 1.5.1.0

i am trying to create a order and assign a shipping no for that order when a order is placed. But i see that when i have an invoice created and a shipment added , magento sets the order status to 'complete' automatically. I tried to change the status manually but it wouldn work.
$order = Mage::getModel('sales/order');
$order->loadByIncrementId($orderId);
$order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true);
$order->save();
Could some one suggest me how to over come this?
Also, how i add a custom carrier ? The default ones are DHL, FedEx , UPS.. I want to add one similar to them. This is how i am doing it:
$carrier = "dhl";
$title = "DHL";
$trackNumber = '538099';
if (1) {
$itemsQty = $order->getItemsCollection()->count();
$shipment =Mage::getModel('sales/service_order',$order)->prepareShipment($itemsQty);
$shipment = new Mage_Sales_Model_Order_Shipment_Api();
$shipmentId = $shipment->create($orderId);
$shipment->addTrack($shipmentId,$carrier,$title,$trackNumber);
}
For the carrier and title, if i give a custom name, i get a error invalid carrier in a report. How do i go about this? Thanks.
You could use the addStatusToHistory function. This is also used for adding comments.
$order->addStatusToHistory('processing', 'Order is being processed', false);
param 1 (string): The new status
param 2 (string): Your Comment
param 3 (boolean): If you want to send the customer an email notification.

Magento - Customer Not Logged in After Redirect From External Page

I'm having a lot of trouble getting a customer to stay logged in after I have created a new account. I'm creating them an account and adding products to a cart from an external site, and then sending them to Magento store. What I want to have happen is:
A customer goes to a signup page and enters relevant information.
They go to a new page where they can choose to add free samples to their cart.
After picking samples. their account is created and they are redirected to the Magento store with the samples in their cart.
The problem I'm having is between steps 2 and 3. I create an account using the Magento's SOAP API with the following:
$customerInfo = array('firstname' => $custFirstname, 'lastname' => $custLastname, 'email' => $email, 'password_hash' => md5( $new_password ), 'store_id' => 34, 'website_id' => 25,'group_id' => 9);
// Call API method customer.create
$newCustomerId = $client->call( $session, 'customer.create', array( $customerInfo ) );
I then return their customer ID, which I pass to another function which actually logs them in and adds products to their cart:
public static function _addSamplesToCart($customer_id, $sample_one, $sample_two, $sample_three){
Mage::getSingleton("core/session", array("name" => "frontend"));
$customerSession = Mage::getSingleton('customer/session', array("name" => "frontend"));
$customerSession->init("customer_bn_us");
$customerSession->loginById($customer_id);
$cart = Mage::getSingleton('checkout/cart');
$cart->addProductsByIds($idArray);
$cart->save();
$cart->getCheckoutSession()->setCartWasUpdated(true);
}
These functions are actually called from AJAX post requests, so when I get a successful return value from _addSamplesToCart, I do a simple javascript redirect (window.location ="http://www.myhostname.net/welcome") and it correctly takes me there, but I'm not logged in.
I've been looking around all afternoon and trying a few different things and nothing has worked. I've also tried doing a hidden form submit to /customer/account/loginPost and it still doesn't work. I have verified that it's correctly creating an account in Magento. My only hunch is that I'm doing this with a mix of AJAX and PHP so somehow the cookies or sessions are getting mixed up?
If you are trying to login from an hostname different from the one used by the Magento store, it cannot work. You can verify this by checking if a frontend cookie is created after the AJAX call.
I suggest you to create a new controller in Magento that receives the id of the customer just created and executes the code you wrote in your function:
www.myhostname.net/autologin/myaction/13 (where 13 is the id of the customer just created).
Obviously you should add something else to avoid security issues.

Resources