I'm trying to follow a tutorial I found on youtube using bumbummen99's shopping cart package about storing instances into the database, but I'm getting an error that it can't store the cart using the same identifier.
Here's the code when I'm storing the instance:
public function render()
...
if(Auth::check()){
Cart::instance('cart')->store(Auth::user()->id);
}
Since the instance is getting stored before I can add a product to the cart, it doesn't save the product inside the cart after logging out.
With the fact i have only minor experiences with persistent shopping carts, i found it weird it didn't have an update() method.
In your case, i would assume you should erase() the cart before saving it again, to ensure the correct cart is in the database.
Cart::instance('cart')->erase(Auth::user()->id);
Cart::instance('cart')->store(Auth::user()->id);
In general saving the cart seems like a challenge, i would assume the best practice is to save on logouts, as the session will persist and this should not be done in context of render calls. Or with a button to actually save the state of the cart for later.
Related
In Presta 1.6 there was the possibility to use the JS ajaxCart Object to add ajax functions to alter your products before they are appended to the Cart. I am trying to rediscover such an ability in Presta 1.7 where apparently the ajaxCart Object is no longer defined.
Unfortunately I do not have code or anything to show, I simply would need to know whether there is a proper way now, a hook or anything, to modify your products before adding them to the Cart?
If there is no proper way, I would also be thankful for improper ways. Did the ajaxCart Object get a different scope? Was it replaced by another mechanism? Unfortunately I did not succeed a whole lot in reverse engineering the changed.
Json view of my paypal after payment is made
I am desperately trying to access the description which is under the transactions array but can't seem to find a way!
It's totally different if I want to access payment_method for instance all I do is this:
(By the way, I assigned this array to $method)
$method->payer->payment_method , but the same thing doesn't work if I want to access description. All I get is an error.
I'm using laravel 5.5, in case that makes a difference.
I'm doing this because I need to find a way to reference my product in the final page after the paypal payment has been made.
Looks like transactions in an array so if you would like the description of the first one that would look like this.
$method->transactions[0]->description
i've a problem with paypal integration in magento.
If i choose paypal standard payment and confirm order, i'm correctly redirect to paypal site for payment, but if i press back button on the browser i am redirected in /checkout/cart (that is empty) and in my backend my order was placed and in PENDING status (it's not shown in customers order list)...
This happens because the order were placed before payment processing...
In OnepageController.php saveOrderAction method i can see
$this->getOnepage()->getQuote()->save();
/**
* when there is redirect to third party, we don't want to save order yet.
* we will save the order in return action.
*/
if (isset($redirectUrl)) {
$result['redirect'] = $redirectUrl;
}
What does it mean? It is exactly what i want "Don't want to save order yet....", unfortunatly few rows before...
$this->getOnepage()->saveOrder();
$redirectUrl = $this->getOnepage()->getCheckout()->getRedirectUrl();
And the order were already placed....
I hate editing core file, but i've tried to comment the line above, but an exception shows me that order information are used inside paypal module itself (Standard.php file method getStandardCheckoutFormFields). So i can't modify core file easily....
What am I missing?
Thanks a lot and excuse me for my bad english.
You can use for this purpose PayPal express checkout. It works the way you want.
I'm dealing with exactly same problem as you were.
For now i'm thinking of rewriting onePage Model and saveOrder action in my module.
What Im thinking of is to remove part where session is cleared and make an event to observer after receive payment method response.
No idea if it'll work but well.
I am trying to customize a module, and need to call the cart items inside a model from the backend (adminhtml) while creating an order from backend. Calling Models('checkout/session'), ('checkout/cart'), and helper doesnot seem to work. Does getCustomercart() works or shall I try anything else ?
For backend orders you have access to the 'quote' object like this:
Mage::getSingleton('adminhtml/session_quote')->getQuote().
See what else you can use from the class Mage_Adminhtml_Model_Sales_Order_Create. That's the model that handles the backend order creation.
I am writing a custom shipping rates module, and I can’t seem to figure out how to get the estimate shipping zipcode… I know how to get the zipcode once the order has been created, but not for the estimate shipping portion of the checkout process
Any input is greatly appreciated!
Jeff
Whole information about the customer's cart is kept in Mage_Sales_Model_Quote model until placing an order. So you can get the Shipping Address model from the Quote. And from Shipping Address model you can get the zip code, which is called a 'post code' there. Thus, the only thing you initially need is to get Quote for the customer.
The Quote can be got in different ways:
loaded from DB by its id or by any other attribute
received from the Checkout session
received from the Checkout Cart model
The most general way is to get Quote by loading it from DB - this can be done in all the Magento workflows and areas (API, frontend, backend, etc.).
But for your case the most straightforward way is to get Quote from Checkout Cart model, as you don't need to know Quote id for it - at frontend Magento loads Cart with appropriate customer data automatically.
/** #var $cart Mage_Checkout_Model_Cart */
$cart = Mage::getSingleton('checkout/cart');
$quote = $cart->getQuote();
$shippingAddress = $quote->getShippingAddress();
$zip = $shippingAddress->getPostcode();
To get a little more understanding, why the Checkout Cart is used in this approach: the Checkout module manages the whole checkout process at frontend. It processes composing cart, viewing it, going through checkout steps and placing an order. Checkout module also stores the customer's quote model in its Cart model. While Quote stores whole information and can be used everywhere to manipulate customer's cart, the Cart model is just a temporary service model to aid Checkout module in fulfilling its duty, and it can be used at frontend for current customer.
you can do something like:
Mage::getSingleton('checkout/session')->getQuote()->getShippingAddress()->getPostcode();
//or
Mage::getSingleton('checkout/session')->getQuote()->getBillingAddress()->getPostcode();