Jump to content

Trying to modify Prestashop for "samples" function - could use a little help...


Recommended Posts

I need some collaboration on this project. It's not a huge thing, but it's going to be very usefull when it's done.

I am using and making modificattions to PS ver. 1.1.0.5 (Ver. 1 Final).

I want to use the add to cart (add_to_cart) function to add a "sample" to the cart. I've created the display box for the front office.

Because most of prestashop's code is still mostly a mystery to me, I need some coding help or a few strings of code.

The size/amount of the sample is unimportant, as it changes with the particular product anyway. What I want is for the add_to_cart function to put the product in the cart at FREE or $0.00 (dollars for my side of the pond) if it's a sample. I want to add a prefix of "Sample" or "Samp" to the listing in the cart, and to the eventual order invoice and subsequent email confirmation and shop email notifications.

I know I'm probably not the only one who'd like to see a samples function.

(Because I've altered my Prestashop so much over the past year+, I won't be able to upgrade it until I get it on an SVN server... so I'm writing these "sample" changes for this version.)

Link to comment
Share on other sites

Alright - here's where I am so far: I have the show-noshow function for 'samples available' working in the front and back office. You check a box that says there are samples, you get the samples available box on the product page. I have created the database column, the on/off function, and even cleaned it up in the back office so it looks like it came with PS.

Now I need help with the functions in the shopping cart area.

Currently when I click my "Send me a Sample" button, I get it to go into the cart, but it still puts it in as a regular product ie: case, description, and price.

What I really need is help locating the part of the add_to_cart functionality that actually gets and reports the price when the product is added and displays in the cart itself.

Once I have that done, the changes will work and it looks great, like a regular part of PrestaShop and not a hack.

Link to comment
Share on other sites

Somebody has to know where I should look in the code for the parts I need to alter/add to/rewrite to make this work. Please help me with some direction for what file to look in, maybe if you know, pinpoint the code? I NEED this to work soon.

Where in Prestashop does the Add to cart button get the command to put the price in the cart?

Do I need to register a 'function' in init.php to have the shop recognize what a sample is?

Do I need to define a sample in JSON?

Can this be done simply by (copying and then) altering the add_to_cart code in ajax-cart.js?

I'm swinging in the wind here.... :-S

Link to comment
Share on other sites

the code to add somthing to the cart is

$result = $cart->updateQty(intval($qty), intval($idProduct));

you can see this function in more details in the classes/Cart.php

I suspect you may wish to change the cart.php in the home folder (as well as the ajax to check for your sample products and add them at £0, or you could alter the product.php in the home folder to add a buy now button for a sample which passes though the product to the cart.php at no cost.

Hope that helps

Link to comment
Share on other sites

  • 1 year later...
  • 1 year later...
×
×
  • Create New...