I know that setCouponCode is catch inside __call in Varien_Object but I can't figure out where it is defined.
I need it because I want to show the coupon code even if the discount equal zero.
I believed it's done inside this function.
So if anybody know where the function is defined or where I can modify the code to get the coupon code displayed all the time, please let me know.
Most text editors have a 'search in files/folders' option. Open the source folder and search for function __setCouponCode.
Ok I figured it out.
the SetCouponCode is setting the value for coupon_code in the magic function.
Related to this, did anybody notice that the quote is not being deleted properly? I say it is related to this because the coupon code variable keeps the value [if any] after you delete a product from cart.
Try:
1. Set some Shopping Price Cart Rule to a product and make it display a banner on the header section for example.
2. Add product to checkout/cart in order to trigger the rule and show the banner on the Cart.
3. Delete the product from cart and you will see the banner still showing on the header section.
Note. If you have another product in cart this will not work because when you delete the one that triggered the rule&banner the Coupon Code will get replaced with the one that belongs to this other product in cart.
SO this bug only works if only the product that triggers the rule&banner is in cart.
If anybody has a fix on this or can replicate these conditions: I'd love to have a conversation about magento's deficiency to make a proper product delete from cart - which implies a proper quote refresh.
Reference:
- app/code/core/Mage/Sales/Model/Quote.php -> public function removeItem($itemId)
And yes, magento core issue.
Related
I want to add a checkbox for the product to indicate if needs assemble or not,if yes, then more money will be charged. My products are shown as grouped style, like:
I am using a plugin called woocommerce extra product options, which can add the checkbox before "add to cart" button. As:
But I want to add the checkbox to each line of the simple products under the grouped product instead of only one; like:
I checked the documentaion, it says use following to hook the extra item in the code/page you want.
function my_custom_function(){
do_action("woocommerce_tm_epo");
}
add_action( 'woocommerce_before_add_to_cart_button','my_custom_function');
But I tried, it always shows only one before add to cart button regardless how many time "add_action('woocommerce_before_add_to_cart_button','my_custom_function');" it is called. How can I achieve my goal? Thanks in advance.
I also tried do_action("woocommerce_tm_epo"); only, but it is not showing anything. If I use do_action("woocommerce_tm_epo"), from screen I can see the space for the checkbox, but just showing the blank. I checked the firebug, I can see the checkbox is there, but for some reason is being hidden. I checked the corresponding CSS, find one place Visbility:hidden; after I changed it to visbility:visable. Still shows blank. Already sitting on the chair for this more than 13 hours, hope someone can help or provide helpful advices.
I've setup a WooCommerce variable product with a 'Free Trial' and 'Single Payment' option. I want to stop repeat purchases of the trial product for obvious reasons.
The following example shows how this can be done: https://gist.github.com/bekarice/0143d1b423857b0c6885
This example works as described with a products ID (which is set with the following variables):
$non_purchasable = 356;
$no_repeats_id = 356;
Unfortunately the code seemingly doesn't work when the above variables are set to the specific products 'free trial' variation ID.
Is there a way to modify the above example to work with a products specific variation ID?
Are you sure you are setting the correct variation ID? I've included an image below for reference:
For anyone else who gets stuck, please ensure that your past order history (for the user placing the order) is deleted. Once I deleted my order hostory this code started working as planned.
You can use the wordpress-Woocommerce plugin to prevent repeated purchase. Mostly useful for downloadable products.
The following plugin is do the same thing.
https://codecanyon.net/item/woocommerce-disable-repeat-purchase/22249871
I successfully generated a test cart rule and assigned to my user.
I can see it both in backoffice and on the my-account page under 'my vouchers'. So we're sure it's recorderd and assigned.
What happens is that in shopping-cart page, even after loggin in with my user, I can't see any voucher field.
Digging deeper, I can say that the $discounts template var is not populated, or, simply it counts zero. So I took a look to the controller, and saw it assign it via $order->getCartRules(). And getCartRules simply reads a db table. And surprise?? The order_cart_rule table is empty. So it doesn't get populated. So what could be the problem here? Ever had same issue someone? It's a strange thing..
Probably the main question is: where/when exaclty do the cart and the rules get created/applied? I can see in FrontController the cart being created, but at that point it seems the cart rules are not setted yet.
By the way, I'm running on latest prestashop 1.6.1.4
$order->getCartRules
The function $order->getCartRules() gives you the list of cart rules applied to this order (you can find it in a table ps_order_cart_rule).
Where are all cart rules?
All cart rules are in the table ps_cart_rule.
If you have marked a cart rule as Highlight - you can see this:
If you have added any cart rule to your shop - you can see this:
If you can't see Vouchers field - either you don't have any cart rules or your theme installed isn't supporting it.
is a late answer but i noticed that if you enable paypal it has in paypal.js a line that remove not only the voucher area but also the trashcan to delete a product:
see pic: https://i.gyazo.com/403a9004aaa745a2817f11884d52346b.png
/* 1.5 One page checkout*/
var qty = $('.qty-field.cart_quantity_input').val();
$('.qty-field.cart_quantity_input').after(qty);
$('.qty-field.cart_quantity_input, .cart_total_bar, .cart_quantity_delete, #cart_voucher *').remove();
by renaming the cart_voucher to cart_voucher_2 (if you not use express checkout) and cart_quantity_delete to cart_quantity_delete_2 you will return to have your things right :)
I am looking for a way adding a product to cart without display it.
Example:
New customer order -> welcome letter in the cart, but the customer doesnt see it.
The added product cost always 0 €, so it never changed the shopping cart total.
The solution should be changed as few as possible.
Any idea?
Thank you!
(Sorry for my very bad english...)
I would say to change the formulation a bit and add it to the order just before the order is saved. While the quote is being converted into an order (sales_model_service_quote_submit_before is one good event here, but there are others), add the product to the order.
This way, you don't have to hack around trying to hide items in the cart, and the effect is the same.
Two options:
Define a new product type that extends the Virtual product type in Magento, and then use a custom Item Renderer for Checkout and Cart that doesn't output any html. Here's a useful tutorial for that process.
Define a new boolean product attribute called "cart_visibility" or something like that, override DOCROOT\app\design\frontend\base\default\template\checkout\cart\item\default.phtml in your own theme and test for that value before outputting the item's attributes e.g. on line 28:
<?php if($_item->getCartVisibility(){ ?>
Don't forget to close the brace at the end of the file obviously.
if it's 0 then why add it to the cart just add it as a message to cart page by adding it to cart template or injecting your own block to this template
I have one certain product that needs to be in the cart under certain circumstances. I have been looking at the Ubercart api documentation and I don't see any hooks that would be the obvious place to see if a certain item exists prior to checkout.
I could use the hook_add_to_cart hook to add the special item whenever the first item is added, but I'm concerned that the visitor may remove the item and then complete the purchase without the required item.
Any suggestions how to make sure the special item is in the cart on checkout?
You can have a module and run something like:
function mymodule_init() {
if (preg_match('/checkout/', request_uri()) {
$items = uc_cart_get_contents();
foreach ($items as $item) {
// code
}
}
}
That will fire up on the checkout page, and fetch the cart contents. Everytime they hit the checkout page, uc_cart_get_contents() returns the cart contents.
http://www.ubercart.org/docs/api/uc_cart_get_contents
There are probably better ways to do what you want to do though, like using a Conditional Action to prevent checkout if Item B is in the cart but Item A is not. You can also look at Product Kits, but I don't have much experience with that.
From what you have said it sounds as though the product kit module might be very much worth looking into as a way of ensuring any items associated with the main product are kept in the cart.
Product kit comes as part of ubercart and you will find it on the modules page under 'Ubercart - extra'. If this is no good then we can see about using the API :)
An old question, but I found a great solution.
hook_uc_cart_item_delete() functions specifically on certain entities when they are removed. You can just set this hook in your module, check for the specific entity being removed that is dependent on the other item, and then use uc_cart_remove_item() on the item you want to remove.