I am using codeigniter cart for online commerce, and i still confuse how to make coupon which automatically update the total cart when coupon code found for an items.
Thanks
Each and every coupon is stored in Database. So in database table there are some important fields.
Coupon Code #ex 007AbC0098
Value of coupon #ex 3%
If its for product then product ID #ex 25
First user add items to cart and the at show cart option you will allow to add the coupon. So when user add the coupon, check if coupon is valid. If its valid
Get the value of the coupn
Get the session cart total value $this->cart->format_number($this->cart->total());
And make the calculation in local
Add that to privet session and before check pay, check the session has some of values.
If yes deduct it from total, else proceed to Payment.
If its only for and product. Get the product id from coupon table, and do calculation and proceed.
References
CodeIgniter Shopping Cart Sample - FormGet.com
You can do a for each loop through each item in the basket.
change the price of each item manually (percentage off), this percentage can be taken from the DB.
Once the price has been changed, you can:
$this->cart->update($data); where $data is the name of the array that was iterated over.
Related
I have a requirement in my website where the customer can buy a certain product only once. If they try to buy that again it should throw an error saying cannot purchase this again.
Please help me on this.
If it is only one or few products like that - the best way in my opinion is to add attribute to customer and change it after product is purchased.
Thanks for your question...
Solution:-
1- You've to create product attribute as Yes/No & by default, it'll be No.you've to select as Yes for the product which you want to avail purchase only once.
2- If a customer is logged in, then during Add to Cart if a product can purchase only once for a customer then before adding to cart(use observer here) you've to check if a customer already purchases this item if yes then you've to avoid
Add to Cart else customer can add this to cart.
3- If a customer is not logged in, in this case, it depends on you.
There may be 2 cases:-
a- Simply customer can be added to cart any item & after login, if a customer has added the restricted item(only once purchase) then you've to remove the restricted item from the cart if already purchased else vice versa.
b- OR you don't allow to Add To Cart(by an observer) restricted item if a customer is not logged in.
Hope it'll resolve your problem.
If a customer is logged in and chooses a bundle product and puts it into their shopping cart, everything is okay. All Taxes and Subtotals are included if I look into the invoice.
A special customer has a 5% discount of every product (via a shopping cart rule) and chooses a bundle product and put its into the shopping cart. Again, everything is okay.
But if the special customer adds a coupon code (about 20€), the tax and the subtotal equals 0 and the price is not correct. It equals something magical.
Change the variable data type from int to float. You are likely using Data Type integers, which can not represent decimal places (e.g .0001). Therefore, your numbers are being rounded down and changing results. Hope this helps, if not, please post your code so we can actually help rather than making assumptions.
I need a coupon code in magento. But the condition is one user can use the code more then one time. But cant't get more discount then code discount amount.
Like admin create a coupon code of $100 fixed amount. But my first order total $70. So if I use this code I will get $70 discount. For next when I use same code, I want $30 discount. That process will go until I get full amount($100) of discount.
Is that possible in magento?
i am using magento 1.7.0.2.In sales_flat_order_item table i have created a field "real_original_price" where i storing product's original price(in case of special price).Price is storing properly.Now problem is how do i show the real_original_price field's data in my invoice page .Actually my target is showing user discounted amount in invoice that is (original price - sell price). How do i achieve this.any idea
https://www.sonassi.com/knowledge-base/magento-kb/display-attributes-on-invoice-or-packing-slip-in-magento/
You can write an observer on order save or invoice save event. In the observer you can fetch the original price from catalog_product_entity and update in sales_flat_order.
I'm having some problems getting my Magento Cart Rules to apply.
What I am trying to do is encourage users to purchase gift cards, so if you purchase a gift card you get 10% off the entire transaction assuming you purchase 2 or more items (including the gift card).
This is what I am using at the moment:
In Conditions
If ALL of these conditions are TRUE :
Total Items Quantity equals or greater than 2
If an item is FOUND in the cart with ANY of these conditions true:
SKU is 7667 (Gift Card)
In Actions
Apply Fixed amount discount for whole cart
Discount Amount 10
All the rest are as default.
Any help would be greatly appreciated
Your conditions seem to be correct. But in actions you have defined a fixed amount discount instead of a percent discount.
In Actions:
Apply Percent of product price discount
Discount Amount 10
Also you have to keep in mind that this way someone could simply put 2 giftcards in his cart to get the discount. You should add another rule check for an item where SKU IS NOT 7667.