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
Related
My web site requires that I use an add-to-cart shortcode to add my products to the basket, however when I do so it doesn't show the details of the variation in my basket
Originally I was just using...
https://evolvefitness.co.uk/checkout/?add-to-cart=9327
...to add the variation but I thought I may need to be more specific so changed it to the below link...
https://evolvefitness.co.uk/checkout/?add-to-cart=9275&variation_id=9327
Unfortunately I still don't get the variation description that I do when I go into the product itself and make the selection process normally.
It's strange because it is selecting the correct product variation and you can see that when you hover over the links in the Cart, it just doesn't seem to want to display.
Do I need to add some more detail to the add-to-cart link that I'm missing?
Thanks for any help
To give you the following answer, I first tried to monitor the outgoing traffic in both cases, both when the request to add to the cart is made directly, and when you do it through the link you provided. Here's what I found and what you could do:
While your requests are GETs to which you pass parameters, what is done directly is a POST with more parameters in the query. Here is a direct example
// Your GET request
https://evolvefitness.co.uk/checkout/?add-to-cart=9275&variation_id=9327
where the parameters are the add-to-cart and variation_id
// The direct POST request
https://evolvefitness.co.uk/shop/warrior-tribe-transformation/?attribute_duration=8+week+programme&attribute_location=Evolve+Blackfriars&attribute_time=08%3A10
and the parameters are the following
attribute_duration: 12 week programme
attribute_location: Evolve Blackfriars
attribute_time: 08:10
quantity: 1
add-to-cart: 9275
product_id: 9275
variation_id: 9310
Therefore, after some trial and error I found the correct link you want to have to make the correct GET, of course choosing your parameters values
// Solution GET
https://evolvefitness.co.uk/checkout/?add-to-cart=9275&attribute_duration=12+week+programme&attribute_location=Evolve+Blackfriars&attribute_time=08%3A10
Hi all I will go straight to the point. I found out that when i create a shopping cart price rule in magento and added a promotion/coupon code as indicated above with all rules set correctly to have a discount works from the frontend as expected from customers checkout experience/process.
But when i try to create an order from the backend/admin and trying to apply the promocode1 coupon code to the order for a specific customer it shows it to be invalid. as indicated above.
My Version i am using currently is ver. 1.9.3.6
I hope someone can point me to the right direction or what i may be doing wrong or not doing.
snap shots below
Thanks.
This looks like a bug in magento as after several checks i realized that you have to select 'all store view' option during the creation of the price rule.
Even though you select the specific store view for the price rule, the coupon will not be applied to the order from the backend of magento without you selecting the 'all store view'.
I know this thread is old but I am also getting the same error messages and i resolve my issue by removing the fields reset_shipping: true from sales.js file in js/mage/adminhtml from function applyCoupon. In myside whenever i am applying coupon code then my shipping price is going to reset so coupon code could not apply if shipping price is 0 ( my coupon code is to offer free shipping)
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 :)
On my homepage for my shop I currently have a featured products area. The problem is it shows the price including the tax rate where throughout the site I've got it set up to display without the tax & then for the the tax to be added on within the cart.
I'm using the following code for my featured products pricing.
<p class="price">£<?php echo Mage::helper('tax')->getPrice($_product, $_product->getFinalPrice(), 2);?>(+VAT)</p>
is there a simple way to force the outcome excluding tax as it seems to be ignoring my general settings?
It also seems to ignore the general rule for decimal places too. If I need to post the full code please just say.
The third parameter of Mage::helper('tax')->getPrice() function indicates if price have to be shown with or without tax. So either set it to null or just drop it.
For the rounding issue please try Mage::helper('core')->currency() instead of Mage::helper('tax')->getPrice(). So your final code should look like this:
echo Mage::helper('core')->currency($_product->getFinalPrice());
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.