Community Add-Ons
Imprint Text Options
for osCommerce Online Merchant v2.2
you can have a lot of text options, to be assigned with product, and
set different options enabled for different products, using checkboxes, when
add/edit product.
so, for example, you sell mugs with imprinting, then you can assign fields
'name' and 'date of birth' to mug_1 product, 'date' and 'phrase' with mug_2, so
customer will fill this fields and it will be stored into db.
ps: BACKUP BEFORE INSTALLING! :)
Fixed the product_info.php file.
This is a full package.
Support thread:
http://forums.oscommerce.com/index.php?showtopic=147933&st=0
Fixed mistakes in coding in the following files:
admin/invoice.php
admin/packing_slip.php
checkout_process.php
account_history_info.php
This is a full package.
Support thread:
http://forums.oscommerce.com/index.php?showtopic=147933&st=0
Fixed coding errors in admin/orders.php and product_info.php. See support thread for details.
Support thread:
http://forums.oscommerce.com/index.php?showtopic=147933&st=0
Imprint has had problems keeping track of sessions, i.e. if two users were logged in to the shop and ordering exactly the same product then both would have orders stored in the database with exactly same text. It's because imprint 1.3.1 seems to have problems in getting session ID.
So I have done some modifications to the original imprint 1.3.1 by running diffmerge against my own (already heavily modified) web shop and comparing to OSC22RC1. I gathered all the changes into one document.
I have not tested the changes on an unmodified web shop and I believe there are still some problems to be ironed out as far as product attributes are concerned. I.e. my fix does not work in my web shop on products that do not have separate attributes (like colour or size) with separate stocks kept for them.
If anybody can test my modifications on a standard osCommerce 2.2 and give me some feedback, that would be very appreciated.
Thanks and enjoy!
Hi, everybody!
As I was thinking of using the imprint option quite extensively in my site I did also some checking of the tables and code supporting the option. I have discovered a serious flaw in the option that MIGHT create unpredicted results in your site.
As far as I understand - guests get their basket contents stored in a cookie, while the text attributes get stored in a table that is connected to the guest's session via the session ID. The problem is that the application never gets the session ID and thus it stores an empty value (null?) in the underlying table.
For those who want the above gibberish translated into English: if you have TWO non-registered guests on you site SIMULTANEOUSLY and they order exactly the same item, but with different texts, they will both get THE SAME TEXT. I believe it will be the last input text that "wins".
I have produced a fix that I am testing right now at my own site. The fix involves getting the session ID into $osCsid from $_REQUEST["osCsid"] or from $_GET["osCsid"], depending on where in the php code you are. My fix seems to work, but I don't really know if it's done the correct way as I don't know a jacksh.t about PHP/MySQL programming and was just trying to make a crude fix to a serious problem. Anyway, I'll post the fix in a few days and will be glad if somebody can review it.
Example of one of the fixes in application_top.php:
$osCsid = $_REQUEST["osCsid"];
tep_db_query("insert into zjsess(sessid, place) values ('" . $osCsid . "','application_top 3 (insert)')");
tep_db_query("insert into customers_basket_text_attributes values ('$osCsid', " . $HTTP_POST_VARS['products_id'] . ", " . $attr['products_text_attributes_id'] . ", '" . addslashes($HTTP_POST_VARS['products_text_attributes_' . $attr['products_text_attributes_id']]) . "');");
Primeiramente gostaria de agradecer o DENUZ e todos que ajudaram a desenvolver essa maravilhosa contribuição
que me ajudou muito na hora que eu mais precisava!
Em 2º Lugar: Gostaria de Agradecer a Adriana, que posto no fórum o link dessa contribuição, bj para ela :)
Bom, agora vou postar aqui uma coisa que não consegui fazer com as contribuições, que é mostrar o
"Imprint Text Options" na Página account_history_info.php.
ATENÇÃO BACKUP ANTES MODIFICAR! :)
1º INÍCIO (START)
Abra o Arquivo "account_history_info.php"
Procure pelo código:
for ($i=0, $n=sizeof($order->products); $i<$n; $i++) {
echo ' <tr>' . "n" .
' <td class="main" align="right" valign="top" width="30">' . $order->products[$i]['qty'] . ' x</td>' . "n" .
' <td class="main" valign="top">' . $order->products[$i]['name'];
if ( (isset($order->products[$i]['attributes'])) && (sizeof($order->products[$i]['attributes']) > 0) ) {
for ($j=0, $n2=sizeof($order->products[$i]['attributes']); $j<$n2; $j++) {
echo '<br><nobr><small> <i> - ' . $order->products[$i]['attributes'][$j]['option'] . ': ' . $order->products[$i]['attributes'][$j]['value'] . '</i></small></nobr>';
}
}
2º FIM (END)
Substitua (Replace) por esse código.
for ($i=0, $n=sizeof($order->products); $i<$n; $i++) {
echo ' <tr>' . "n" .
' <td class="main" align="right" valign="top" width="30">' . $order->products[$i]['qty'] . ' x</td>' . "n" .
' <td class="main" valign="top">' . $order->products[$i]['name'];
if ( (isset($order->products[$i]['attributes'])) && (sizeof($order->products[$i]['attributes']) > 0) ) {
for ($j=0, $n2=sizeof($order->products[$i]['attributes']); $j<$n2; $j++) {
echo '<br><nobr><small> <i> - ' . $order->products[$i]['attributes'][$j]['option'] . ': ' . $order->products[$i]['attributes'][$j]['value'] . '</i></small></nobr>';
}
}
// denuz text attr
$attr_q = tep_db_query("select ota.*, pta.products_text_attributes_name from orders_text_attributes as ota, products_text_attributes as pta where ota.orders_id = " . $HTTP_GET_VARS['order_id'] . " and pta.products_text_attributes_id = ota.products_text_attributes_id");
while ($attr = tep_db_fetch_array($attr_q)) {
echo '<br><nobr><small> <i> - ' . $attr['products_text_attributes_name'] . ': ' . stripslashes($attr['products_text_attributes_text']);
echo '</i></small></nobr>';
}
// eof denuz text attr
// Jeferson Ivo - Brasil 05/02/2009 ##ÓD##
Hi everyone,
This will display products attributes within order confirmation email sent by oscommerce.
Modification of checkout_process.php is required.
Hi everyone,
This will display products attributes within order confirmation email sent by oscommerce.
Modification of checkout_process.php is required.
This is the fix for the error that appear when you change the product name of an order that was ordered before.
Hi,
there is an error into the code that will appear on customer order if you change the product name of an ordored product.
see my post in the thread here :
http://forums.oscommerce.com/index.php?showtopic=270881&st=0&p=1112795&#entry1112795
is anybody able to fix it
nothing to download just a comment
Please download 1.3.1 version of imprint as this is only the mods not the rest of the files. Shortly I will package it all together and upgrade the version with e-mail support from previous.
Forgot (again :-)) to mention:
Step 1. --------> Open classes/order.php
<-------------FIND THIS:
$products_tax = $this->products[$index]['tax'];
$products_tax_description = $this->products[$index]['tax_description'];
if (DISPLAY_PRICE_WITH_TAX == 'true') {
<------------ADD ABOVE:
//CENTRAL50 CHARGE PER CUSTOM
$check_query = tep_db_query("select products_id, customqty from customers_basket_text_attributes_qty where session_id = '" . $osCsid . "' and products_id = '" . $this->products[$index]['id'] . "'"); //also text option
$check = tep_db_fetch_array($check_query);
if ($check['customqty'] > 0) {
$charge = $check['customqty'] * 5; //Change value to whatever you want to charge per custom
$shown_price = $shown_price + $charge;
$this->info['subtotal'] += $charge;
}
//CENTRAL50 CHARGE PER CUSTOM
Make sure you change the value in the above code to what ever you want to charge per customized entry.
Its updated in this package.
Okay everyone, I rewrote the code today. I am going to publish it in a package on the contrib page. I urge everyone (as will be noted on contrib page) to use this new contrib.
For my purposes, I only needed 1 text option per product (name). But yesterday I realized that my mod only allows that. So if you installed it, and you used more then one text per name (name, color) it would not work.
So I re-wrote it, shortened up some of the queries, etc. I would like to clean up the code a little more, but for now it works and I wanted people to download the new one not the old one before I went on vacation.
I also took out the check box option. Again, after realizing the people have more then one text option on a product page, it would look redundant. Now the system will recognize if there is text entered into that specific field or not. It will then run the rest of the system accordingly.
Please note for the other contrib, the charge per custom field contrib I wrote, that will be updated as well. You should note this:
You have a product page with two fields on it: Name, Color
----A customer buys that product with both fields filled out.
The system will charge that customer for 1 Custom entry. Not two. Charging for every entry in one qty would not make sense.
Same goes for if the custom adds two of those products to their shopping cart, the first one has only the Name field entered and the second one has the Color field entered. The system will charge them for two customizations.
Understand? I want to make that as simple as possible.
It would not make sense if you had color, name, age, size, etc. on each product page and charged for each one. If you want to do that, let me know, and I will see if I have time to rewrite the code to do so.
Other wise, like I said:
1. Customer buys product (1 qty) with two fields(name,color) filled out.
---System charges the customer for one customization.
OR
2. Customer buys more then 1 of the same product (xx qty) and fills out the two fields(name,color) for each qty differently - Example:
product = bottle
[b]Name | color[/b] (fields)
Jon | blue
mind | (blank)
over | (blank)
(blank | matter
Now thats the qty of 4 for the same product (bottle). The system will charge them for 4 customs. Not 8, that would not be right.
And so on for every other product in their shopping cart.
Okay, I will release the new contribs a little later.
Now to install:
What does this do? Well, there has been a lot of talk about how its dumb why a customer can't add the same product with another field.
What this does is add the second customized entry to the same column in the database, but puts a seperator of "|---|" in between the multiple entries.
You can change it to what ever you want, but do remember that there is two instances of this in this code, and they must both match for it to work.
I also added a check box on the product_info.php page where the customer selects whether they want to customize or not. This will stop the mod from
adding an empty value in. Of coarse I could rework it to see if its empty to just not insert it, but I am tied up enough to even write this mod for
everyone.
Another feature is that it now adds a numeric value (new column in database) per customized field. Even if the customer gets 3 of the same product,
and two of those have customized fields tied with it, the value will be shown as 2. This is more primarly for the other contrib I released, where
you can now charge per customized entry (it uses this value).
I would seperate it for this contrib, but tell you the truth I dont have the time to do so.
USE AT YOUR OWN RISK. AND ALWAYS BACK UP BACK UP BACK UP
I am always still learning in coding, so anyone who has even better knowledge could clean it up if they want.
This does what its supposed to do for me and thats all I need.
----This is the complete package. New directions and new code. This comes with two text files for using More Entries, and Charge which requires More Entries.
Its complete, with the missing code and everything now in here. Enjoy
Woops, forgot to mention to change the value of what you want to charge. Fixed it, same package as below with the added note.
What does this do? Well when a customer adds a customized field to your product, it will add the fee with it in their checkout.
<-------THIS REQURIES THE "MORE ENTRIES" MOD that I released. It works off of that, so you need to install it.--------->
If they bought more then 1 of the same product, and has multiple customized names, this will still calc how many customized fields there is,
and give the charge.
USE AT YOUR OWN RISK. AND ALWAYS BACK UP BACK UP BACK UP
I am always still learning in coding, so anyone who has even better knowledge could clean it up if they want.
This does what its supposed to do for me and thats all I need.
What does this do? Well, there has been a lot of talk about how its dumb why a customer can't add the same product with another field.
What this does is add the second customized entry to the same column in the database, but puts a separator of "|---|" in between the multiple entries.
You can change it to what ever you want, but do remember that there is two instances of this in this code, and they must both match for it to work.
I also added a check box on the product_info.php page where the customer selects whether they want to customize or not. This will stop the mod from
adding an empty value in. Of coarse I could rework it to see if its empty to just not insert it, but I am tied up enough to even write this mod for
everyone.
Another feature is that it now adds a numeric value (new column in database) per customized field. Even if the customer gets 3 of the same product,
and two of those have customized fields tied with it, the value will be shown as 2. This is more primarily for the other contrib I released, where
you can now charge per customized entry (it uses this value).
I would separate it for this contrib, but tell you the truth I don't have the time to do so.
USE AT YOUR OWN RISK. AND ALWAYS BACK UP BACK UP BACK UP
I am always still learning in coding, so anyone who has even better knowledge could clean it up if they want.
This does what its supposed to do for me and thats all I need.
This package comes with the install text, not the full package of the whole contrib.
This is much requested, so therefore i post this here. I use the contribution Email invoice 1.0 and used the new template file: box_invoice.php
Great contribution but the attributes weren't included into the packing slip and invoice. This package includes both files edited. Replace and enjoy!
*This file is an add-on to the original Imprint Text Options. Please download the original file first.
Updated /admin/orders.php to correctly return apostrophes in product names without throwing an error.
Added update instructions below to install.txt
Added screenshot
Great contrib. Thanks to Denuz for writing it and FalseDawn for the education in tep_db_input.
Enjoy!
In the admin/orders.php file. There is a critical syntax error.
Just add this section instead of the one in the file.
Have also updated the attached package as well.
// denuz text attr
$pid = @mysql_result(tep_db_query("select products_id from products_description where products_name='" . $order->products[$i]['name'] . "'"), 0, "products_id");
$attr_q = tep_db_query("select ota.*, pta.products_text_attributes_name from orders_text_attributes as ota, products_text_attributes as pta where ota.orders_id = " . $HTTP_GET_VARS['oID'] . " and ota.products_id = ' . $pid . ' and pta.products_text_attributes_id = ota.products_text_attributes_id");
while ($attr = tep_db_fetch_array($attr_q)) {
echo '<br><nobr><small> <i> - ' . $attr['products_text_attributes_name'] . ': ' . stripslashes($attr['products_text_attributes_text']);
echo '</i></small></nobr>';
}
// eof denuz text attr
2 small fixes:
- add the line below to admin/includes/filenames.php
define('FILENAME_TEXT_ATTRIBUTES', 'text_attributes.php');
- add the line below to admin/includes/languages/english.php
define('TEXT_DISPLAY_NUMBER_OF_TEXT_ATTRIBUTES', 'Text Attributes Total: ');
that's it.
- fixed problems when osc attributes also submitted to product
- added table definition
support forum: http://forums.oscommerce.com/index.php?showtopic=147933
sorry, i forgot lang translation file.
full package
- fixed bug when delete product from shopping cart
- added web interface for adding new attributes
previous archive was broken, posted again.
you can have a lot of text options, to be assigned with product, and
set different options enabled for different products, using checkboxes, when
add/edit product.
so, for example, you sell mugs with imprinting, then you can assign fields
'name' and 'date of birth' to mug_1 product, 'date' and 'phrase' with mug_2, so
customer will fill this fields and it will be stored into db.
ps: BACKUP BEFORE INSTALLING! :)
