I've built an observer that listens to the registration_success_observer event that is emitted upon new user registration (from the accounts page). The observer handles various functionality, most importantly upgrading the user to a membership group if a membership id is passed in.
The problem is that I need to have the same functionality for users who are checking out AND signing up as a new customer. I somehow need a way to figure out if they are signing up as a new customer (via event?) from the one page checkout screen, in addition to re-calculating the totals -- some items in our store have special pricing for groups.
Does anyone know the best way to go about this? Specific events that I should listen for, or any other code snippets for handling functionality within the one page checkout screen would be helpful.
** Update **
It just occurred to me that a customer isn't actually created until after the order is complete. Any workarounds for this?
You could create your own 'custom event' using the logic below to check which method they use to check out on success.phtml or incorporate it in sales_order_place_before
$quoteId = Mage::getModel('sales/order')->loadByIncrementId($this->getOrderId())->getQuoteId();
$quote = Mage::getModel('sales/quote')->load($quoteId);
$method = $quote->getCheckoutMethod(true);
if ($method == 'register'){
//the customer registered...do your stuff
}
Source : http://www.magentocommerce.com/boards/viewthread/273690/#t375160
But what your trying to do may not be possible without rewriting the onepage checkout, because a customer is created before order is store in the db but after processing the credit card so the amount the credit card is bill for wouldn't equal the order total.
You could try to add a third option to the first step in the checkout process ('register as a member') that allow them to create an account before start checking out.
Related
I'm trying to make plugin for Shopware6 that adds choice of period of delivery (for example, user can chose product to be delivered March 07 9:00-11:00). Problem is that can't be more than 15 orders in each period. So if used proceeds to make Order from Cart, and if period he chose has more than 15 orders, I must somehow invalidate form and tell to user to chose another period.
So I must:
somehow subscribe to the event "user makes an order from card",
check if chosen period is correct,
if not, tell it to user and don't create an order.
Is there any way to do it? In Symfony, I would just add validation to entity PeriodOfDelivery. But in Shopware I cannot do it because controller is in Shopware Core and I cannot edit it.
You can subscribe on CartConvertedEvent::class event. You can get original and converted cart data from the event.
In subscriber, you can do any check that you need and throw a specific exception.
You can implement your own exception class. use \Shopware\Core\Checkout\Order\Exception\DeliveryWithoutAddressException as template. In your own exception, you can specify own error code and message.
There is a choice of “SALE” or “AUTHORISATION” in the Magento Paypal settings. We ideally wish to stay with “SALE” as that covers 99.9% of anything we do (we always have goods in stock). The “Authorisation” option worries me with the 3 day limit, plus it adds an extra “capture” step that could go wrong later.
So…….
“SALE" works fine but in Magento it automatically creates an INVOICE in the system. Other payment systems we use such as Sofort AG make this setting optional and for a very good reason.
Magento is set so that once you have produced an INVOICE and a SHIPMENT it automatically marks any order as COMPLETE.
We create UPS labels, with a tracking number which of course is added to the SHIPMENT details. So my problem is:
As soon as we try to create a UPS label (without even printing) Magento sets the Paypal orders to COMPLETE. This is because it has seen an INVOICE
and a SHIPMENT for an order.
We need to disable a Paypal “SALE” from producing an invoice. We can easily produce and send the invoice once the shipment has been produced
and sent, and then set it finally to Complete.
Is there a setting I have missed to disable this forced invoice? I can see a company used to make a module for this purpose but it is out of date for Magento 1.9. (I did try it just in case!!)
http://www.magentocommerce.com/magento-connect/disable-automatic-generation-of-invoice.html
No, there is no setting to fix this: paypal create an object called transaction and this kind of object should be created with the object invoice. It's not a good practice to don't create invoice and I suggest you to stay away to any component that don't create a transaction.
Probably it works well, but in the flow of order creation when you will evalutate to play with order status. Anyway there is not a setting to do this.
I've implemented a custom payment method in magento. In short, it works the following way:
upon checkout, the user gets redirected to the bank
he enters his credit card info, returns to a landing page
landing page querys the bank for the results and sets the order/payment status accordingly
Also, since the user might not return:
a cron querys the bank every minute for the status of the pending payments and updates them if neccessary
The problem: when the cron runs at the same time the user is returning, the payment statuses get updated twice, two invoices are generated, two emails are sent, etc.
There must be a proper way of handling this. Maybe locking the order/payment entity somehow? I'm kind of new to magento. Please share your knowledge!
Im using one page checkout and I need to pass few information after payment has been successfully made. I have used sales_order_payment_pay, checkout_type_onepage_save_order_after, sales_order_payment_place_end & checkout_onepage_controller_success_action events. But these events are triggered as soon as clicking on place order. Even if the payment is failure also its triggering that event. I need to pass information only on successful payment.
sales_order_payment_place_end should be good enough. Just add whatever logic you need to use. You can grab the $payment from the $observer and the $order from the $payment
Try looking into $payment->getAmountAuthorized If the payment succeeded this should be greater then 0.
EDIT: $observer->getEvent()->getPayment(); (should work)
Normally the Status of an Order changes After Payment notification. You can watch for Status change have a Look at:
http://www.cartware.de/blog/detail/article/kein-magento-event-fuer-statusaenderung/
Its written in german Language but by watching the Code you may get the clue
I have a subscription service that people pay monthly for, so I’ve setup a “Virtual Product” with a Recurring Profile. At the same time, I want to have it so they can add different one time products. To accomplish this I’ve tried creating a “Bundled Product” with all the different one time products and adding the “Virtual Product” to that “Bundled Product”.
However, when I go to checkout it says “Nominal item can be purchased standalone only. To proceed please remove other items from the quote.” How do I allow people to subscribe to the service and purchase the products at the same time?
Note: I am using Paypal Website Payment Pro as my merchant account.
Here's the comment from Magento code:
/**
* Temporary workaround for purchase process: it is too dangerous to purchase more than one nominal item
* or a mixture of nominal and non-nominal items, although technically possible.
*
* The problem is that currently it is implemented as sequential submission of nominal items and order, by one click.
* It makes logically impossible to make the process of the purchase failsafe.
* Proper solution is to submit items one by one with customer confirmation each time.
*/
Actually you can remove the code below:
if ($item->isNominal() && $this->hasItems() || $this->hasNominalItems()) {
Mage::throwException(Mage::helper('sales')->__('Nominal item can be purchased standalone only. To proceed please remove other items from the quote.'));
}
Magento still handles multiple nominal products, however, you use that with your own risk.
Unfortunately this is a hardcoded restriction in the Mage_Paypal code.
You can see in Mage_Sales_Model_Service_Quote::submitAll() that it executes submitNominalItems() which contains:
$this->_validate();
$this->_submitRecurringPaymentProfiles();
$this->_inactivateQuote();
$this->_deleteNominalItems();
So, it kills the Cart after submitting nominal items. I'm not exactly sure why it does that, but I assume it's due to the way that subscriptions are created at Paypal.
Here is the code that prevents adding items to a cart that contains nominals in Mage_Sales_Model_Quote::addItem():
if ($item->isNominal() && $this->hasItems() || $this->hasNominalItems()) {
Mage::throwException(Mage::helper('sales')->__('Nominal item can be purchased standalone only. To proceed please remove other items from the quote.'));
}
I'm working on using Magento's Recurring Profiles for other payment providers at the moment (its a background task: Magento Recurring Profiles with non-Paypal payment method) and it is possible to checkout both nominal (aka subscription) and real products at the same time, but it does make it quite a bit more complex.
If this is a big deal, it should be possible to refactor the Mage_Paypal code to do this, but it's a complicated task that can't really be answered in a single post.