Jump to content

Automatically Add Paid Product To Cart


Recommended Posts

Hello Everyone,

 

Thank you in advance for reading this and any help you may be able to provide.

 

Im trying to set up my shop so that a paid product ($1) is added to the cart on every order. I would like to pair this with a discount on the order of $1 essentially making the product free without it showing up as a free item during checkout.

 

Just to clarify I am looking for a free work around not a paid module preferably and I do not want to use the free gift option, I am currently using it but my payment processor payza cannot process items under $1 during checkout so i have to find a work around to make the item show up as a paid product over $1 to payza but in reality have a discount that makes the product free ie

Example Order:

$10 paid product

$1 gift product

=$11 total 

-$1 Discount 

The checkout total = $10 Making the gift free but showing it in checkout to payza as a $1 purchase

Edited by courtneyb (see edit history)

Share this post


Link to post
Share on other sites

You will have to edit some code in order to make it fit your particular case.

 

I would approach this by creating an override for function processChangeProductInCart() from controller CartController and before the CartRule code hardcode the add of your gift product like this:

if (!$this->context->cart->containsProduct(*Gift product id*)) {
    $this->context->cart->updateQty(1, *Gift product id*);
}

After you see that the gift product is added to cart you can add from Back Office a Cart Rule to give a discount an amount equal with the price of the gift product.

 

Some additional code you might want is to prevent the gift product to be removed from cart if it contains other products and autoremove the gift if the cart contains only the gift.

Share this post


Link to post
Share on other sites

  • 2 weeks later...

I decided to set up a freebies section place the products with regulat price tag on it and a note - discoutn reflected in cart. Then i made a cart rule discounting the product price automatically without voucher once it is added to the cart. This seems to work better because it allows the customer to choose the attributes before they add the product to the cart plus it limits the number of free products to 1 after that the regular price is charged. Thanks for the response though gabdara :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More