Product detail page dropdown color or sizes save with order

MoverRen

Avatar: MoverRen

2015-01-19 20:08

Hello,
I am using Quick.cart 6.2 for quite some time and I am very satisfied with it.
Until now I have managed to do all kinds of changes, but what I can't resolve is product attributes which was OK in old QCart.
I need this more than anything else in Quick cart.
What I am referring to is simple drop down <select> -><option> list in product details page so the customers can chose size or color of that product. I know how to add the list, but it seems that I don't know how to include selected option value in order and save it and send it with e-mail.
I suppose it is something like including VAT but I can't do it.
Please help

» Quick.Cart v6.x

Product Attributes

MoverRen

Avatar: MoverRen

2015-01-20 03:30

I was trying with option drop-down list, but it can be a single input field for customers to enter like shoe size, shirt color and size, something like that.
It must be possible to add one field in product details page, and pass it's value to db and order. I tried on test QC but can not make it to save and send value of the field.
Please help,
Thanks

Product Attributes

boboo

Avatar: boboo

2015-01-20 06:22

It is a little bit more work than with SimpleVat.
You have to create a DB with the attributes and link it to produtcs similar to ProductsFiles (1 product can have more photos, 1 photo can be used by more products).
Then you have to add the attribute(s) name(s) to the product name when it is landing in the basket (additional fields in DB_BASKET_TEMP) and add these fields in the DB_ORDERS.
But handling the basket and order you must differ the products with the same ID (iProduct) but different attributes.
Because if You put (example) 1 pair shoes "lion" size X into basket, and then 1 pair shoes "lion" but in size Y,
the last taken shoes will overwrite the first one, and in the basket (and later in the order) you will find 2 x "lion" size Y.

Of course it is possible to solve it, but not a 5 minutes job.
I think it is my first time on this forum, where I will write: consider the Ext Version of QC.
:-)

boboo :-)

MoverRen

Avatar: MoverRen

2015-01-20 12:48

Boboo,
Thanks for the reply.
What you are explaining is too complex, I know that.
It should be much simpler to add one text input field in product details page, so the customers can enter text manually lets say shoe number as 38, or black for color.
What is the most important after entering field value should go to order and to be emailed to admin together with Product Name, quantity and price.

Yes I need the input field just like quantity in basket without recount or other functionality, just text input. Can you try to explain if it is possible to add just that field in product details page, or in the basket if it is simpler.

boboo

Avatar: boboo

2015-01-20 17:46

Only one field (written by customer) it is easy.
But You must live with the eventuality that if the customer wants to buy the same (example for him and his son :-) ) shoes but in different sizes - it will "crash".
If You're agree with this "feature", I can put a solution here.

boboo :-)

MoverRen

Avatar: MoverRen

2015-01-20 18:32

Thank you very much for taking time to resolve this for me. I appreciate that.

So, I am up to this solution if you can post or send it to my mail. Address will be in signature.
I will test it before real use, so if it crashes, doesn't matter.

What I would like to do is to put user input field/s( one for size and one for color, or just one if easier for you) in product detail page between available and price on the right side next to product photos.

In that field/s customer can manually enter size and/or color and after that by clicking Buy Now he will be taken to Basket as usual and after that to order etc. User input should be visible at least in Order details page (order-print) and sent to mail with other order data about ordered product/s.

Also this field should be individual (can be left blank or filled and entry should affect only product in question (something like Product New Field but with user input instead of admin input).

Thank you again,
hope I can help you with something some time.

I think you will understand what I mean. If you can do this, can you please do it in a plugin manner (edit this ->change or add this line etc). I am familiar with PHP and HTML, but the script is complex and I would like to do this from the first try.

ivica.marasevic@gmail.com

boboo

Avatar: boboo

2015-01-20 19:18

I'm going to solve it as follows:
the color and/or size will be added to the product name, when landing in basket.
E.g.
No attributes:
shoes lion
With attributes (different causes):
shoes lion / size: 38 / color: sahara
shoes lion / color: brown
shoes lion / size: 42
And this would be saved into the order as the product name.
NO SEPARATE FIELD in orders_database.

The "solving action" will only touch the basket function and the product detail view template.
The <selects> elements with options lists (sizes, colors) You must fill by yourself directly hardcoded in the template.
If You want to fill them in admin panel and i should do it, it will take more time and probably a PayPal contact :-)

Is it ok?

boboo :-)

MoverRen

Avatar: MoverRen

2015-01-20 19:32

Let's go with that solution, hope it will work, thanks

ivica.marasevic@gmail.com

MoverRen

Avatar: MoverRen

2015-01-21 01:00

I would like to try with hard coded solution, then I can create product template for adults, kids, shoes etc. Copy - Paste and rename, then choose appropriate template for product I am entering.
Thanks

ivica.marasevic@gmail.com

boboo

Avatar: boboo

2015-01-21 07:32

So, let's begin (and finish :-) )
/templates/default/product.php
under (it must be within <form> element):

<input type="hidden" name="iQuantity" value="1" />


add:

<?php
if($aData['iProduct']!=12){ // this php part is needed only if you want exclude some products from the size&color chosing possibility (in this example product id 12 will not have these options)?>
size: <select name="sProductSize" value="">
 <option value="36">36</option>
 <option value="38">38</option>
 <option value="40">40</option>
</select>
color: <select name="sProductColor" value="">
 <option value="brown">brown</option>
 <option value="black">black</option>
 <option value="sahara">sahara</option>
</select>
<?php
}
?>


/templates/default/order-step-1.php
under:

$iQuantity $_POST['iQuantity'];


add:

$sProductSize=isset($_POST['sProductSize'])?$_POST['sProductSize']:null;
$sProductColor=isset($_POST['sProductColor'])?$_POST['sProductColor']:null;


/core/orders.php -> function saveBasket
under:

$iOrder $_SESSION['iCustomer'.LANGUAGE];


add:

$sProductSize=isset($GLOBALS['sProductSize'])?' / size: ':null// these strings "/ size:" and "/ color:" you can put into $lang database
$sProductColor=isset($GLOBALS['sProductColor'])?' / color: ':null;


and replace (still in save Basket function):

'sName' => $oProduct->aProducts[$iProduct]['sName']


with:

'sName' => $oProduct->aProducts[$iProduct]['sName'].$sProductSize.$GLOBALS['sProductSize'].$sProductColor.$GLOBALS['sProductColor']



That's all.
Install, test and then report here.

boboo :-)

MoverRen

Avatar: MoverRen

2015-01-21 11:56

Thanks Boboo,
your code works great while testing and I cant see why it wouldn't work on server. It is clean and simple, very nice.

Just for a thought, is it possible to add ProductNewField to admin panel for option listing in select option and then take value and put it in <option> part
Something like

 size: <select name="sProductSize" value="">
 <option value="<?php echo $aData['sField1'];?>"><?php echo $aData['sField1'];</option>
<
option value="<?php echo $aData['sField2'];?>"><?php echo $aData['sField2'];</option>
<
option value="<?php echo $aData['sField3'];?>"><?php echo $aData['sField3'];</option>
<
option value="<?php echo $aData['sField4'];?>"><?php echo $aData['sField4'];</option>
 
</
select>
color: <select name="sProductColor" value="">
 <
option value="<?php echo $aData['sField5'];?>"><?php echo &

#36;aData['sField1'];?></option>
<option value="<?php echo $aData['sField6'];?>"><?php echo $aData['sField1'];?></option>
<option value="<?php echo $aData['sField7'];?>"><?php echo $aData['sField1'];?></option>


</select>

Might work

MoverRen

Avatar: MoverRen

2015-01-21 12:29

Sorry for this mess above.

Thanks Boboo,
your code works great while testing and I cant see why it wouldn't work on server. It is clean and simple, very nice.

Just for a thought, is it possible to add ProductNewField to admin panel for option listing in select option and then take value and put it in <option>...... </option> part
Something like


                           size: <select name="sProductSize" value="">

<option value="<?php echo $aData['sField1'];?>"><?php echo $aData['sField1'];?></option>
<option value="<?php echo $aData['sField2'];?>"><?php echo $aData['sField2'];?></option>
<option value="<?php echo $aData['sField3'];?>"><?php echo $aData['sField3'];?></option>
<option value="<?php echo $aData['sField4'];?>"><?php echo $aData['sField4'];?></option>

                          </select>

                          color: <select name="sProductColor" value="">

<option value="<?php echo $aData['sField5'];?>"><?php echo aData['sField5'];?></option>
<option value="<?php echo $aData['sField6'];?>"><?php echo $aData['sField6'];?></option>
<option value="<?php echo $aData['sField7'];?>"><?php echo $aData['sField7'];?></option>

                         </select>



This is how I have added drop down list before I've post my question on the forum. What I couldn't do (didn't know how), is to register/define values of variables ProductSize and ProductColor from <SELECT>...</SELECT> in order to be saved an emailed.

I will test more and probably modify the code to get the most of it.

Thank you.

PS
I would like to erase the messed up post above, but I don't see the option for that. If someone can erase it please

Might work

boboo

Avatar: boboo

2015-01-21 12:30

for me, i would do it this way:
extend the products_fields with: 'aColors' and 'aSizes'
(/database/_fields.php -> $aProductsFields)
add the input fields (name="aColors" and name="aSizes") into admin product view (the <input> names must correspond to fieldnames in DB).
now you can write into these inputs some values separated by... "," (for example comma [or another character]). Needed for later "explode".
Then write a small function in /core/products.php which will create the <select> with <options> filled with values from aColors and/or aSizes.
And put the returned value of the function instead of the select-construction in my post above in the /templates/default/product.php
Adjust the names in $_POST (from 'sProductSize' to 'aSizes') and i think that's all.
And you will have individual colors and sizes for every product.

boboo :-)

MoverRen

Avatar: MoverRen

2015-01-21 13:32

Thanks again Boboo,
It seems to be a little problem when I try to add $lang['size'] and $lang['color'] instead of ' / size: ' and ' / color: ' in ORDERS.PHP

What I did is:


public function saveBasket$aData$bAdd null ){
    if( isset( 
$aData ) && is_array$aData ) ){
      
$iOrder $_SESSION['iCustomer'.LANGUAGE];

      
$sProductSize=isset($GLOBALS['sProductSize'])? $lang['size'] :null// these strings "/ size:" and "/ color:" you can put into $lang database
      
$sProductColor=isset($GLOBALS['sProductColor'])?' / color: ':null;

      
$oFFS FlatFilesSerialize::getInstance( );
      
$oProduct Products::getInstance( );



but value of $lang['size'] doesn't display in basket, and on PRODUCT.PHP works OK

What did I go wrong

boboo

Avatar: boboo

2015-01-21 14:56

Because "closed" function does not see the global variables outside of her.
You can (all inside of saveBasket function):
1. directly as the first line under declaration add: global $lang;
now the function sees the $lang array that was declared outside of her.

or

2. just use $GLOBALS['lang']['size'] instead of $lang['size']


in /templates/default/product.php the code is executed in "globally environmet" (without encapsulating in functions), so the php code sees the global variables.

boboo :-)

MoverRen

Avatar: MoverRen

2015-01-21 15:21

Thanks, it works.

One more question
I would like to enable display of PagesShortDescription if it exists under pages links in left menu, so it can look like NEWS. That option exists when page has subpages and they can be shown on parrent page in the manner Link + Short description + featured image.

Can I do that kind of display in left menu. Subpages don't matter, just first level pages.

I have tried to understand how does it work in simpleNews and use that in left menu but the code is very different.

Left menu like Simple News

boboo

Avatar: boboo

2015-01-21 15:41

Of course you can do it.
But you have to change the throwMenu function.
1. Recognize the left menu
2. Recognize the first level
3. Add shortDesc if isset

In another topic i wrote: The QC is the best "raw material" to make all functions and facilities you ever dreamed of.

boboo :-)

MoverRen

Avatar: MoverRen

2015-01-21 15:54

I know that you can do almost anything with the code and that's good, but my knowledge of PHP doesn't go that far.
I have been using QC more than year now and this is my first posting on this forum and I read maybe 150 pages of posts in past time.

Can you help with this Left menu feature.

What and where to change or add in the same plugin manner

I am willing to learn, and I have learned pretty much from just this post.

Left menu like Simple News

bazaroccidental

Avatar: bazaroccidental

2015-01-23 23:41

Thanks for making such thread.
I feel that I am a bit in the same shoes as MoverRen.

I have two questions...
1. Is it possible to make a price difference (ex: size 1= 3,50$ ----- size 2 = 5,00$) depending on the choice of the "size" of the item? It's some kind of calculation, I guess.

2. And to change the "color" of the item for a quantity to add to basket?


If it is not too much to ask...
Thank you very much for your time!

Tomx66

Avatar: Tomx66

2019-03-09 12:06

Hi,
Can help me, v6 quick cart ext. the product attribute the choice should will be not required.
Thanks

Tom

Back to top
about us | contact