We have 2 observers to change product price in the cart : checkout_cart_product_add_after to change price the first time the product is added to cart, and checkout_cart_update_items_after to change price for each item in the cart (when user click the "Modify cart" button on cart page). Both are running OK.
My question : On the cart page, when user clicks the link "Edit" to edit the product in product page (so he can change quantity, ...) and clicks the "Update cart" button, this update button does not read any observer to refresh price. Only the quantity is refreshed.
How to force this "Update cart" (on product page) action to process the code in observer? Is there another observer for this? The code in checkout_cart_product_add_after is executed just the first time the product is added to the cart?
Thanks.
Copy this file:
app\code\core\Mage\Checkout\controllers\CartController.php
To:
app\code\local\Mage\Checkout\controllers\CartController.php
Go to:
public function updateItemOptionsAction()
{
Add your custom logic or fire off a custom event you can listen to and run the same logic on.
Don't forget to flush ;)
Related
Woocommerce is probably working properly but I would like my add to cart on every page to be like the detail/single item page ajax actions.
This is what I want:
add to cart -> top of page says successfully added to cart and update total on top. This is how the detail/single item page cart buttons work.
Instead of :
Currently they add to cart and a view cart button shows successfully on the side instead and not refreshing the total on top.
How can I accomplish this.
Thank You.
If the cart is being updated after you refresh the page, then look at running a refresh after the form submits:
onsubmit="setTimeout(function () { window.location.reload(); }, 10)"
I have a page that displays the contents of a shopping cart in a table. The Quantity field is an editable text box, allowing the user to update its value. I need three buttons - one for Empty cart, one for Update cart, and one for Submit cart.
My ShoppingCartController has these methods:
postCartItem($id)
putUpdateCart()
deleteCartItem($id)
deleteCart
The submit button takes it to the store method of the OrderController resource controller
I'm going out of my mind how to do this RESTfully.
Any tips/best practices would really be appreciated.
I have to achieve the below in Magento. Can anyone please help me in this regard?
on mouse over of "my cart", when there are 1 or more items in the cart, the mini-cart should display -- moving the mouse away causes the mini cart to hide
when adding items to the cart the mini cart should be shown for 10 seconds and then hide
clicking on "my cart" will take the user to the shopping cart page.
It would be great if i get some help on this.
Thanks
Take a look at the block responsible for the Cart Sidebar. This has pretty much everything you need to render the cart items.
The block class is located in /Mage/Checkout/Block/Cart/Sidebar.php
You can create a new block in your header of the type "checkout/cart_sidebar", with a custom template based on the cart sidebar template. You'll also need to update your header template the call the new child block for the mini cart.
<reference name="header">
<block type="checkout/cart_sidebar"
name="mini_cart" as="mini_cart"
template="my_theme/checkout/cart/mini.cart.phtml"/>
</reference>
Then in /page/html/header.phtml make sure you call echo $this->getChildHtml('mini_cart');
This should get you started. To automatically trigger the popup when a product has been added, you need to store a flag in the session, then check for this when the page is reloaded and fire your JavaScript etc. I recommend using an event observer to do this e.g. checkout_cart_add_product_complete
I have a problem with my configurable products (Everything is OK for simple products - Add to cart button is available).
Indeed, in the frontend, these products are displayed but :
The container where I should select values for option(s) does not appear
... CSQ? : The "Add to cart" button does not appear for these products.
I tried and checked:
Status, Visibility, Qty, In stock for Simple products
Attributes
Attributes set
to use a standard theme
Simple products are associated to my configurable products
If I create a new attribute, a new attribute set just for this attribute, 2 simple products and 1 configurable product, I have the same issue... I see my product, but the option remains unavailable.
What is the root cause?
Magento = 1.6.2.0
The following worked for me with this issue:
1) You have to do this for all configurable products
2) Go to the configurable product in "Manage Products" tab
3) Add a space after product name
4) Remove space that you just added
5) Hit the "Save" button
Basically you dont have to change anything just hit the save button. Its very weird but it works for me :P
I'd like to create a new area on the «My account» section that shows to the customer all the products he's been subscribed to by clicking on the «Sign up to get notified when this product is back in stock» button in the product page (a product that is not in stock, of course).
There is other thing that I'd like to do related to this. When customers click on that button, it's still present on the product page, even when the customer has already clicked on it. How can I make this button disappear when the customer has already clicked on it?
I finally found the solution for this. It's really easy. To get the products that a customer has been subscribed to:
$customer_product_alerts = Mage::getModel('productalert/stock')
->getCollection()
->addFieldToFilter('customer_id', $customer_id);
This is for stock alerts. If it comes to price alert, just use the productalert/price model.