Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Adding field to product_info, product list


gazzzzzza

Recommended Posts

Hi

 

I need to modify the function which adds a product to the shopping basket but I can't find it!

 

Basically I need an extra field on the products listing page and on the product_info page where the user has to add a code (for referencing on the clients side)

 

I am going to build the client an admin section to set up an option to turn this functionality on/off for each client. I know how to do this but finding the 'product add' function is really bugging me!

 

My plan is that if the user has the function turned on then the extra field will appear and when they click submit it will check if they inputted a code. If they did not, then it will immediately revert back to the page they just left and display an error. If they did input a code, it will run through the addition of the product to the basket and will add the code into a new table column I have created in the row for that product.

 

So if anyone can help me find this adding product function then I will be most grateful :D

always here to offer some useless advice....

Link to comment
Share on other sites

ok thanks

 

i have been working at it for a while now.

i have added my extra field on the product_info page

 

i have tried to set it up on inlcudes/classes/shopping_cart so that it queries the db to find if the extra field is required for the customer or not. Once this is done it checks if any data was inputted into this field and then either allows the product info to be added to the basket or bypasses the input code.

 

I have put this coding round both of the following fucntions:

 

function update_quantity

function add_cart

 

but it does not seem to stop the code being executed.

 

am i blocking the right bit of code?

 

i looked in application top and it uses these functions i believe to add the data to the basket. so i thought blocking it though the functions wouyld be better so i didnt miss any other places that the function was called.

 

also - i am not sure whether my data is being passed properly although the code is still not stopping the function from adding the product...

 

i have added a field called cccode in product_info - where do i set this value as a global for use in the functions?

 

thanks in advance for any assistance

always here to offer some useless advice....

Link to comment
Share on other sites

I would do the check in application top before it adds the product to the cart and redirects the user to the shopping cart. Also, if you do it in application top, you will still have the values in the form (i think).

 

If you are not sure if the values are working I always use echo $value; to see if anything to coming into the value or something like echo 'HI'; to see if it made it into the if/where/else/for statement.

 

Ryan

If I was crafty, this would be a funny signature.

Link to comment
Share on other sites

cheers

 

i would just like to do

 

$value = $_POST['value']; somewhere if i could so it is easy for me to see that i have the value when im looking at the code and i can see where it came from...it gets confusing when editing so many pages...i sometimes get lost and of course using this method helps with security.

 

ill try and stick the code in application top then

 

any chance you could tell me which lines to block?

 

the bits involving 'case' are confusing me a bit. it would be helpful to me if you could let me know the lines i need to use my code to allow/disallow.

 

thanks for your help

always here to offer some useless advice....

Link to comment
Share on other sites

i think i have blocked the 3 cases that add stuff to the cart

 

1.

case 'add_product' :

 

$cart->add_cart($HTTP_POST_VARS['products_id'], $cart->get_quantity(tep_get_uprid($HTTP_POST_VARS['products_id'], $HTTP_POST_VARS['id'])) + $HTTP_POST_VARS['cart_quantity'], $HTTP_POST_VARS['id']);

 

2.

case 'buy_now' :

 

$cart->add_cart($HTTP_GET_VARS['products_id'], $cart->get_quantity($HTTP_GET_VARS['products_id'])+1);

 

3.

case 'cust_order' :

 

$cart->add_cart($HTTP_GET_VARS['pid'], $cart->get_quantity($HTTP_GET_VARS['pid'])+1);

 

 

 

Where do i modify the variables etc to make sure the field is added to the cart in the products_order table with the other stuff?

always here to offer some useless advice....

Link to comment
Share on other sites

If I were you I might be tempted to add the option_type_feature contrib. That way you could add a text box to product_info.php as an attribute then when you add the product you could check the box in application top a lot easier and add it to the cart a lot easier. It will still be work, but I think it will accomplish half of it for you.

If I was crafty, this would be a funny signature.

Link to comment
Share on other sites

I think it would be far easier to add a text field within a conditional clause - then you don't have to mess with application_top :) (Sorry, I was busy last night and simply answered your "where are the shopping cart add functions" question).

 

You can use the messageStack class for error checking - take a look at create_account.php to see how this is done - keep this within your conditional clause.

 

Matti

Link to comment
Share on other sites

thanks for the help guys

 

right,

 

the client has changed his mind...

he now wants the extra field to always show (so we can get this done quicker!) and it to be an optional field so they don't have to enter data in it. But this still leaves me needing to grab the inputted data which is where i am struggling...so simple usually but not in oscommerce :D $_POST['gimme_the_info_lol'];

 

any ideas how i get it on the next page and stick it into the shopping basket and, in turn, the orders table?

 

thanks for your continued assistance

always here to offer some useless advice....

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...