Jump to content
Zappo

[Contribution] Option Types v2

Recommended Posts

I would like to make a modification to the price of the product based on the text the user typed in the textbox. I could set the value price in admin but I would like the amount to change based on the amount of letters.

Example 1-6 letters = $15 and each additional letter is $2.50. I already have the math worked out.

I am just hoping there is someone out there who can tell me how to get the text. I know that in shopping_cart.php it is $attr_value, but how do I get it inside the funtion get_products() located in includes\classes\shopping_cart.php? I know very little php so if you try to explain it please keep that in mind.

Share this post


Link to post
Share on other sites

I thought every thing was working but I have found that the text only shows up through the order confirmation.

The invoice, packingslip only shows CUSTOMER-INPUT .

Logged in if you go to go to account_history_info all I see is -:- ($15.00) for the attribute.

 

I went through the instructions several times and compared the files in the contributions with my files and can't figure out what I have missed. Can someone please help me figure out what I am doing wrong.

Share this post


Link to post
Share on other sites

I thought every thing was working but I have found that the text only shows up through the order confirmation.

The invoice, packingslip only shows CUSTOMER-INPUT .

Logged in if you go to go to account_history_info all I see is - :- ($15.00) for the attribute.

 

I went through the instructions several times and compared the files in the contributions with my files and can't figure out what I have missed. Can someone please help me figure out what I am doing wrong.

 

Are you using the Paypal IPN module, if so it will produce the CUSTOMER-INPUT error

---------------

I'm using Option Types 2.1.3 and solved the problem as follows:

 

Integrating with other Contributions (Paypal IPN)

from Paypal IPN v2.3.3 install_guide_READ_ME.html

 

Note: Rule of thumb - whenever you make ANY change to checkout_process.php you MUST manually merge the change into paypal_ipn.php and ipn.php

 

The PayPal IPN works different from other payment modules and bypasses the checkout_process file. Which means that any contribution which modifies the checkout_process.php file will require some manual coding TLC in paypal_ipn.php and ipn.php.

 

From version 1.3 of this module, the PayPal IPN Payment Module is compatible with the Register Globals Patch v1.4 - you do not need to make any modifications for this.

 

Version 2.0 introduces a new code base so any fixes posted for versions 1.x probably won't work without modification.

---------------------

I had to modify /includes/modules/payment/paypal_ipn.php

At line 249 (a single line change only)

to match change in checkout_process.php line 230 which was changed by Option Types 2.1.3 contribution.

 

as follows:

 

$sql_data_array = array('orders_id' => $insert_id,

'orders_products_id' => $order_products_id,

'products_options' => $attributes_values['products_options_name'],

// BOF - Zappo - Option Types v2 - ONE LINE - Update insert query. changed to use value from $order->products.

'products_options_values' => $order->products[$i]['attributes'][$j]['value'],

// EOF change added by ADM

'options_values_price' => $attributes_values['options_values_price'],

'price_prefix' => $attributes_values['price_prefix']);

Share this post


Link to post
Share on other sites

I'm using 2.1.3

 

I have all my options and attributes with a "sort_order"

 

When I put a product with several attributes into the cart, the attributes appear in the correct sort order.

However if I go to "checkout" but then return to the cart, the attributes have lost their sort_order

 

There is a similar problem in Admin in

packing_slip

invoice

 

Anyone know how to keep the attribute order consistently correct.

Edited by doon1947

Share this post


Link to post
Share on other sites

Hi Gabriel, how did you manage to solve the problem with updating quantities/deleting items in the cart?

The Update and Remove buttons don't show at all any more (nor the number of items in the cart)!

Thanks in advance,

Andrej

 

I've been lurking here for about 2 weeks now, and I thought I was close on my own changes to /includes/classes/shopping_cart.php. I've gotten past the issue with updating quantities/deleteing items out of the cart ...

post-310084-0-44800500-1337718837_thumb.jpg

Share this post


Link to post
Share on other sites

After some research I figured that probably the file "catalog/shopping_cart.php" is the culprit.

 

In optiontypes231 install package I think something is not right with this file.

In "catalog" folder - with files to be simply added to oSc 2.3.1 installation - there are two files: "catalog/shopping_cart.php" and stylesheet.css, which cannot be just copied over oSc 2.3.1 since they are from 2009.

On the other hand in "install.txt" file there are instructions for modifying "catalog/shopping_cart.php" file of 2.3.1 oSc, but under B) there is some code to replace which can not be found in 2.3.1 oSc; and if all the changes are made the result is like in the picture in previous post - no "Update" butten or "Remove text".

 

Since I don't know programming - can somebody please help?!

 

 

Hi Gabriel, how did you manage to solve the problem with updating quantities/deleting items in the cart?

The Update and Remove buttons don't show at all any more (nor the number of items in the cart)!

Thanks in advance,

Andrej

Share this post


Link to post
Share on other sites

Hi, I'm looking for something that allows customers to select multiple options and quantity for each options. Does this contribution allow that?

Share this post


Link to post
Share on other sites

Hi, I'm looking for something that allows customers to select multiple options and quantity for each options. Does this contribution allow that?

 

Same here I need to be able to select multiple attributes for a single item

Share this post


Link to post
Share on other sites

Whenever I try importing the .sql file I keep getting this error from phpmyadmin

 

Erreur

 

Requête SQL:

INSERT INTO configuration VALUES ('', 'Use Progress Bars?', 'OPTIONS_TYPE_PROGRESS', 'Both', 'Set to use the Progress bar for Text Options<br>None = No Progress Bars<br>Text = Textfields only<br>TextArea = TextAreas only<br>Both = Both Text Fields and Areas', last_insert_id(), '4', now(), now(), NULL, 'tep_cfg_select_option(array(\'None\', \'Text\', \'TextArea\', \'Both\'),'), ('', 'Upload File Prefix', 'OPTIONS_TYPE_FILEPREFIX', 'Database', 'The prefix that is used to generate unique filenames for uploads.<br>Database = insert id from database<br>Date = the upload Date<br>Time = the upload Time<br>DateTime = Upload Date and Time', last_insert_id(), '5', now(), now(), NULL, 'tep_cfg_select_option(array(\'Database\', \'Date\', \'Time\', \'DateTime\'),'), ('', 'Delete Uploads older than', 'OPTIONS_TYPE_PURGETIME', '-2 weeks', 'Uploads in the Temporary folder are automatically deleted when older than this setting.<br>Us[...]

MySQL a répondu:

#1062 - Duplicate entry '0' for key 'PRIMARY'

 

Anyone knows what I am doing wrong?

Edited by GLime

Share this post


Link to post
Share on other sites

I have installed on OS 2.3.1 and everything is sort of working except in the shopping cart it will not display any of the new options. For example, a text field will show on the item, but once you type and add it in the cart, the cart does not show the info from the options. Also when trying to purchase an item, it gives me another error.

 

I am thinking this problem is related to the shoppingcart.php...does anyone have the good update files, there is clearly something wrong with the install instructions.

Share this post


Link to post
Share on other sites

I have installed on OS 2.3.1 and everything is sort of working except in the shopping cart it will not display any of the new options. For example, a text field will show on the item, but once you type and add it in the cart, the cart does not show the info from the options. Also when trying to purchase an item, it gives me another error.

 

I am thinking this problem is related to the shoppingcart.php...does anyone have the good update files, there is clearly something wrong with the install instructions.

 

 

THIS IS THE ERROR WHEN I TRY CHECKING OUT ->>>

1146 - Table 'crjcons_finwoodalpha.TABLE_FILES_UPLOADED' doesn't exist

 

select files_uploaded_name from TABLE_FILES_UPLOADED where sesskey = 'mmbrcc8p0soubmsme6fe4aumb4'

 

[TEP STOP]

 

However I look in my database and the tables are there.

Share this post


Link to post
Share on other sites

@@Finwood

 

You didn't define what TABLE_FILES_UPLOADED is, in file catalog/includes/database_tables.php , should be in the instructions or the files supplied

 

I found the additional lines in the older version install file. That seems to fix the login problem, but I still cannot get the shopping cart to populate the new product options. For example, I have a check box and a text field, and when you select, or type into both and hit add to cart, only the item shows in the shopping cart. Any ideas on the proper mod's that need to be made for 2.3.1?

Share this post


Link to post
Share on other sites

HERE IS MY CATALOG/SHOPPING_CART.PHP -

 

 

<?php

/*

$Id$

 

osCommerce, Open Source E-Commerce Solutions

http://www.oscommerce.com

 

Copyright © 2010 osCommerce

 

Released under the GNU General Public License

*/

 

require("includes/application_top.php");

 

if ($cart->count_contents() > 0) {

include(DIR_WS_CLASSES . 'payment.php');

$payment_modules = new payment;

}

 

require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_SHOPPING_CART);

 

$breadcrumb->add(NAVBAR_TITLE, tep_href_link(FILENAME_SHOPPING_CART));

 

require(DIR_WS_INCLUDES . 'template_top.php');

?>

 

<h1><?php echo HEADING_TITLE; ?></h1>

 

<?php

if ($cart->count_contents() > 0) {

?>

 

<?php echo tep_draw_form('cart_quantity', tep_href_link(FILENAME_SHOPPING_CART, 'action=update_product')); ?>

 

<div class="contentContainer">

<h2><?php echo TABLE_HEADING_PRODUCTS; ?></h2>

 

<div class="contentText">

 

<?php

$any_out_of_stock = 0;

$products = $cart->get_products();

for ($i=0, $n=sizeof($products); $i<$n; $i++) {

// Push all attributes information in an array

if (isset($products[$i]['attributes']) && is_array($products[$i]['attributes'])) {

while (list($option, $value) = each($products[$i]['attributes'])) {

echo tep_draw_hidden_field('id[' . $products[$i]['id'] . '][' . $option . ']', $value);

$attributes = tep_db_query("select popt.products_options_name, poval.products_options_values_name, pa.options_values_price, pa.price_prefix

from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_OPTIONS_VALUES . " poval, " . TABLE_PRODUCTS_ATTRIBUTES . " pa

where pa.products_id = '" . (int)$products[$i]['id'] . "'

and pa.options_id = '" . (int)$option . "'

and pa.options_id = popt.products_options_id

and pa.options_values_id = '" . (int)$value . "'

and pa.options_values_id = poval.products_options_values_id

and popt.language_id = '" . (int)$languages_id . "'

and poval.language_id = '" . (int)$languages_id . "'");

$attributes_values = tep_db_fetch_array($attributes);

// BOF Option Types v2.3.1 - REPLACEMENT 6-21-2012

// $products[$i][$option]['products_options_name'] = $attributes_values['products_options_name'];

// $products[$i][$option]['options_values_id'] = $value;

// $products[$i][$option]['products_options_values_name'] = $attributes_values['products_options_values_name'];

if ($value == OPTIONS_VALUE_TEXT_ID) {

echo tep_draw_hidden_field('id[' . $products[$i]['id'] . '][' . TEXT_PREFIX . $option . ']', $products[$i]['attributes_values'][$option]);

$attr_value = $products[$i]['attributes_values'][$option];

} else {

echo tep_draw_hidden_field('id[' . $products[$i]['id'] . '][' . $option . ']', $value);

$attr_value = $attributes_values['products_options_values_name'];

}

$products[$i][$option]['products_options_name'] = $attributes_values['products_options_name'];

$products[$i][$option]['options_values_id'] = $value;

$products[$i][$option]['products_options_values_name'] = $attr_value ;

// EOF Option Types v2.3.1 - REPLACEMENT 6-21-2012

 

$products[$i][$option]['options_values_price'] = $attributes_values['options_values_price'];

$products[$i][$option]['price_prefix'] = $attributes_values['price_prefix'];

}

}

}

?>

 

<table border="0" width="100%" cellspacing="0" cellpadding="0">

 

<?php

 

for ($i=0, $n=sizeof($products); $i<$n; $i++) {

echo ' <tr>';

 

$products_name = '<table border="0" cellspacing="2" cellpadding="2">' .

' <tr>' .

' <td align="center"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products[$i]['id']) . '">' . tep_image(DIR_WS_IMAGES . $products[$i]['image'], $products[$i]['name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a></td>' .

' <td valign="top"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products[$i]['id']) . '"><strong>' . $products[$i]['name'] . '</strong></a>';

// BOF Option Types v2.3.1 - REPLACEMENT 6-21-2012

/*

if (STOCK_CHECK == 'true') {

$stock_check = tep_check_stock($products[$i]['id'], $products[$i]['quantity']);

if (tep_not_null($stock_check)) {

$any_out_of_stock = 1;

 

$products_name .= $stock_check;

}

}

*/

if (STOCK_CHECK == 'true') {

$stock_check = tep_check_stock($products[$i]['id'], $products[$i]['quantity']);

if (tep_not_null($stock_check)) {

$any_out_of_stock = 1;

}

} else {

$stock_check = '';

}

// EOF Option Types v2.3.1 - REPLACEMENT 6-21-2012

/*

if (isset($products[$i]['attributes']) && is_array($products[$i]['attributes'])) {

reset($products[$i]['attributes']);

while (list($option, $value) = each($products[$i]['attributes'])) {

$products_name .= '<br /><small><i> - ' . $products[$i][$option]['products_options_name'] . ' ' . $products[$i][$option]['products_options_values_name'] . '</i></small>';

}

}

 

$products_name .= '<br /><br />' . tep_draw_input_field('cart_quantity[]', $products[$i]['quantity'], 'size="4"') . tep_draw_hidden_field('products_id[]', $products[$i]['id']) . tep_draw_button(IMAGE_BUTTON_UPDATE, 'refresh') . '   or <a href="' . tep_href_link(FILENAME_SHOPPING_CART, 'products_id=' . $products[$i]['id'] . '&action=remove_product') . '">remove</a>';

 

$products_name .= ' </td>' .

' </tr>' .

'</table>';

*/

//BOF Option Types v2.3.1 - Rearanged Product(s) cart-listing, and added Options Column

$products_name = '<table border="0" cellspacing="2" cellpadding="2">' .

' <tr>' .

' <td class="productListing-data" align="center"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products[$i]['id']) . '"><b>' . $products[$i]['name'] . '</b>' . $stock_check . '</a></td>' .

' </tr>' .

' <tr>' .

' <td class="productListing-data" align="center"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products[$i]['id']) . '">' . tep_image(DIR_WS_IMAGES . $products[$i]['image'], $products[$i]['name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a></td>' .

' </tr>' .

'<tr><td colspan="5">';

$products_name .= '<table border="0" cellspacing="2" cellpadding="2">' .

' <tr>' .

' <td class="productListing-data">';

//EOF Option Types v2.3.1 - Rearanged Product(s) cart-listing, and added Options Column

 

if (isset($products[$i]['attributes']) && is_array($products[$i]['attributes'])) {

reset($products[$i]['attributes']);

while (list($option, $value) = each($products[$i]['attributes'])) {

//BOF Option Types v2.3.1 - Rearanged Product(s) cart-listing, added Options Column, Upload preview link, and added Prices to Attributes

$imageDir = (tep_session_registered) ? UPL_DIR : TMP_DIR;

$image_link1 = '';

$image_link2 = '';

if (file_exists($imageDir.$products[$i][$option]['products_options_values_name'])) {

$image_link1 = '<a href="' . $imageDir . $products[$i][$option]['products_options_values_name'] . '" target="_blank">';

$image_link2 = tep_image(DIR_WS_ICONS . 'view.gif') . '</a>';

}

$Option_Price = ($products[$i][$option]['options_values_price'] != '0') ? ' - (' . $products[$i][$option]['price_prefix'] . $currencies->display_price($products[$i][$option]['options_values_price'], tep_get_tax_rate($products[$i]['tax_class_id'])) . ')' : '';

$products_name .= '<small>- ' . $products[$i][$option]['products_options_name'] . ': <i>' . $image_link1 . $products[$i][$option]['products_options_values_name'] . $image_link2 . '</i>' . $Option_Price . '</small><br>';

}

}

 

$products_name .= ' </td></tr></table> </td>' .

' </tr>' .

'</table>';

// EOF Option Types v2.3.1 - REPLACEMENT 6-21-2012

 

echo ' <td valign="top">' . $products_name . '</td>' .

' <td align="right" valign="top"><strong>' . $currencies->display_price($products[$i]['final_price'], tep_get_tax_rate($products[$i]['tax_class_id']), $products[$i]['quantity']) . '</strong></td>' .

' </tr>';

}

?>

 

</table>

 

<p align="right"><strong><?php echo SUB_TITLE_SUB_TOTAL; ?> <?php echo $currencies->format($cart->show_total()); ?></strong></p>

 

<?php

if ($any_out_of_stock == 1) {

if (STOCK_ALLOW_CHECKOUT == 'true') {

?>

 

<p class="stockWarning" align="center"><?php echo OUT_OF_STOCK_CAN_CHECKOUT; ?></p>

 

<?php

} else {

?>

 

<p class="stockWarning" align="center"><?php echo OUT_OF_STOCK_CANT_CHECKOUT; ?></p>

 

<?php

}

}

?>

 

</div>

 

<div class="buttonSet">

<span class="buttonAction"><?php echo tep_draw_button(IMAGE_BUTTON_CHECKOUT, 'triangle-1-e', tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL'), 'primary'); ?></span>

</div>

 

<?php

$initialize_checkout_methods = $payment_modules->checkout_initialization_method();

 

if (!empty($initialize_checkout_methods)) {

?>

 

<p align="right" style="clear: both; padding: 15px 50px 0 0;"><?php echo TEXT_ALTERNATIVE_CHECKOUT_METHODS; ?></p>

 

<?php

reset($initialize_checkout_methods);

while (list(, $value) = each($initialize_checkout_methods)) {

?>

 

<p align="right"><?php echo $value; ?></p>

 

<?php

}

}

?>

 

</div>

 

</form>

 

<?php

} else {

?>

 

<div class="contentContainer">

<div class="contentText">

<?php echo TEXT_CART_EMPTY; ?>

 

<p align="right"><?php echo tep_draw_button(IMAGE_BUTTON_CONTINUE, 'triangle-1-e', tep_href_link(FILENAME_DEFAULT)); ?></p>

</div>

</div>

 

<?php

}

 

require(DIR_WS_INCLUDES . 'template_bottom.php');

require(DIR_WS_INCLUDES . 'application_bottom.php');

?>

Share this post


Link to post
Share on other sites

Steven, check your email, the issue was in file includes/classes/shopping_cart.php

 

To all

 

Checking both, the uploaded file and the manual instructions about file includes/classes/shopping_cart.php, I think they are both wrong, no wonder that it doesn't work

 

Till there is an update to that package, I recommend to use the file from the old package instead and merge it manually into your new file

Share this post


Link to post
Share on other sites

I followed the install instructions for 2.3.1, everything worked except text fields, text areas, and checkboxes. I then applied these changes below and it seems to be working well. Gonna do more tests, but seems good. Thanks.

 

 

@@rknabe - You are right. I had the same problem, I think DunWeb missed a few things. I had to download v2 of option types and look at their versions to compare.

 

In the includes/classes/shopping_cart.php make the following changes:

........

Hope that helps. Share if you find something else that needs modifying! whistling.gif)

Edited by dailce

Share this post


Link to post
Share on other sites

Anyone know how to force only one product per attribute for the text field? Basically if I type something in the text field and add to cart, work as normal - product 1 - quantity 1 - textfield - AAAAA. Now if the buyer goes back and enters something new in the text field - say BBBB - then update the qty to 2 and update the text field. Basically don't allow the cart to add 2 of the same product with 2 different text fields - so we have - product 1 - quantity 2 - textfield - BBBB.

Share this post


Link to post
Share on other sites

Hi,

 

Working on a 2.3.1 site to eventually replace my 2.2Rc2a sites when the time comes, got round to installing this contribution as per my 2.2 sites - thought I had installed wrong, as the admin side did not work the same, then I saw the post by Chris saying he had not updated the Ajax Attribute manager to work with 2.3.1.

 

To my mind this is an essential element of Option Types V2, allowing options to be set from the edit product page.

 

Has anyone started looking at converting this element for 2.3.1 - or should I start breaking things myself?

 

Thanks


Now running on a fully modded, Mobile Friendly 2.3.4 Store with the Excellent MTS installed - See my profile for the mods installed ..... So much thanks for all the help given along the way by forum members.

Share this post


Link to post
Share on other sites

@@Mort-lemur

There was no need for me to update anything at the attribute manager.

Only changes to this are as per my older posts here regarding correct calculation of values, this is same for both versions. Those changes are not implemented in what Chris uploaded

I don't use Chris version, but reading other peoples posts here, it seems that several parts are not working correctly, at least for the shopping cart class, so I would suggest, to use both packages, the last one uploaded by Zappo as a solid working base and Chris version, compare and proceed accordingly

You could also say what is not working for you, changes in admin side are only regarding the admin layout, functionality is same

Share this post


Link to post
Share on other sites

Hi George,

 

The part that is not working for me is the ability to add / amend options via the product edit page. This is understandable as there are no amendment instructions for the relevent page ie admin/categories.php in the version uploaded by Chris.

 

Thanks


Now running on a fully modded, Mobile Friendly 2.3.4 Store with the Excellent MTS installed - See my profile for the mods installed ..... So much thanks for all the help given along the way by forum members.

Share this post


Link to post
Share on other sites

Heather,

the admin/categories.php is not that different in the 231 version, so you could take the one from zappos package and merge manually. Same in any case for includes/classes/shopping_cart.php , I don't know about the other files

 

The attribute manager it self is same, no need to edit anything

Share this post


Link to post
Share on other sites

Thanks George, I will continue trying to merge.

 

I have a feeling it may be something to do with javascript being different in 2.3.1?


Now running on a fully modded, Mobile Friendly 2.3.4 Store with the Excellent MTS installed - See my profile for the mods installed ..... So much thanks for all the help given along the way by forum members.

Share this post


Link to post
Share on other sites

Heather, no, there are no issues with any js used.

 

Just merge the admin/categories.php file, make sure you have the attribute manager folder on the server and to admin/includes/template_top.php add just before </head>

<?php //BOF option types v2
if ($PHP_SELF == 'categories.php' && ($_GET['pID']) && isset($_GET['action']) && ($_GET['action'] == 'new_product') ) {
require_once( 'attributeManager/includes/attributeManagerHeader.inc.php' );
}
//EOF option types v2 ?>

 

and just after </head> add (replacing the <body>)

<?php //BOF option types v2
if ($PHP_SELF == 'categories.php' && ($_GET['pID']) && isset($_GET['action']) && ($_GET['action'] == 'new_product') ) {
echo '<body onLoad="goOnLoad();">';
} else {
echo '<body>';
}
//EOF option types v2 ?>

Share this post


Link to post
Share on other sites

Thank you George - As always you are a star! works like a dream now


Now running on a fully modded, Mobile Friendly 2.3.4 Store with the Excellent MTS installed - See my profile for the mods installed ..... So much thanks for all the help given along the way by forum members.

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

×