Jump to content
Dr. Rolex

jQuery/Ajax Fast checkout/Login/Create account/Shopping Cart/Bootstrap MATC 2.3.3

Recommended Posts

You don't need both plugins. If you only want the Fast Checkout then download the second package that I uploaded.

 

Customers have to sign up, however the sign-up process is included on the Fast Checkout page and it's probably not a lot of work if you want to remove the fields that you don't want.

Look at how other guest checkout plugins work and then apply the same code to this one.

 

whats the best way to move each billing, shipping, payment box under one another?

rather than having the shipping address and other boxes, next to each other, the layout is really messy on the advancesoft demo site and it seems to be stuck in a table.

 

would i have to extract each box from its table layout and put it in seperate div tags?

 

or is the version you've converted already done with div tags?

 

i don't mind digging into the html, and css.

 

i think a numbered section going down the page horizontally seems best for the single page checkout.

 

Or maybe like the truffle shuffle website has done.

Edited by vampirehunter

Share this post


Link to post
Share on other sites

You have to find the Apache error log file. Are you running your own server or are you using some kind of web host?

 

 

From error log:

[21-Jul-2013 16:08:49 America/Chicago] PHP Fatal error: Class 'productListingBox' not found in /(...)/ajax/classes/ajaxManagerTest.class.php on line 1489

 

Line 1489:

new productListingBox($info_box_contents);

 

If I comment that out, the rest of the page will display, and when I put in customer information and hit "Continue" it just reloads that page (ajax_checkout.php).

 

Thanks.

Share this post


Link to post
Share on other sites

Please disregard the above post.

 

I now have the product list showing, but still cannot proceed after entering the customer information. I hit Continue, and it just reloads the page, no user account is being created.

Share this post


Link to post
Share on other sites

Please disregard the above post.

 

I now have the product list showing, but still cannot proceed after entering the customer information. I hit Continue, and it just reloads the page, no user account is being created.

 

Yeah, I found a bug that prevented account creation so I made a temporary fix in javascript that reloads the page to get a new session. However, I have it working for me now so you can try to fix it with this code:

 

In ./ajax/classes/ajaxManagerTest.class.php, Find this code around line 2723

if (SESSION_RECREATE == 'True') {
tep_session_recreate();
}

Replace it with this code:

if (SESSION_RECREATE == 'True') {
tep_session_recreate();
$amSessionVar = tep_session_name().'='.tep_session_id();
echo tep_draw_hidden_field('session_var', $amSessionVar, 'id="session_var"');
}

 

Find this code in ./ajax/javascript/ajaxManager.js around line 63

var arRequestString = new Array;

Replace it with this code:

var arRequestString = new Array;
var url = 'ajax/ajaxManager.php';
if (getElement('session_var') != null) var sessionId = getValue('session_var');

 

Comment or remove the following code, located around line 240 and line 342:

location.reload();

 

Report back if this worked. Also, make sure that Recreate Session is set to true in your admin (Configuration => Sessions).

Edited by Dr. Rolex

Share this post


Link to post
Share on other sites

whats the best way to move each billing, shipping, payment box under one another?

rather than having the shipping address and other boxes, next to each other, the layout is really messy on the advancesoft demo site and it seems to be stuck in a table.

 

would i have to extract each box from its table layout and put it in seperate div tags?

 

or is the version you've converted already done with div tags?

 

i don't mind digging into the html, and css.

 

i think a numbered section going down the page horizontally seems best for the single page checkout.

 

Or maybe like the truffle shuffle website has done.

 

Well, try this:

 

Find in ./ajax/css/ajaxManager.css

#placeorder_area {
width: 100%; float: right; padding: 5px; text-align: left;
}
#payment_area {
width: 49%; float: right;
}
#shipping_area {
width: 50%; float: left;
}
#totals_area{
float: right; width: 100%; border-top: 1px solid black;
}
#products_area {
float: left; width: 100%;
}

 

Replace it with something like this (just an example):

#placeorder_area {
width: 100%; float: right; padding: 5px; text-align: left;
}
#payment_area {
width: 100%; float: right;
}
#shipping_area {
width: 100%; float: right;
}
#totals_area{
float: right; width: 100%; border-top: 1px solid black;
}
#products_area {
float: left; width: 100%;
}
#ajaxManager .ajaxContainer {
width: 100% !important;
float: left !important;
}
#ajaxManager .infoBoxContents {
float: none !important;
}
#ajaxManager p {
width: auto !important;
}

 

Then in ./ajax/classes/ajaxManagerTest.class.php

 

Find around line 2007:

 <p style="margin-top:0px;"><?php echo tep_address_label($customer_id, $sendto, true, ' ', '<br>'); ?></p>
</div>
</div>
</div>

 

Replace with:

 <p style="margin-top:0px;"><?php echo tep_address_label($customer_id, $sendto, true, ' ', '<br>'); ?></p>
</div>
<div style="clear: both;"></div>
</div>
</div>

 

 

I just wanted to show you how it works, it's up to you to make it look good. Don't forget to upload it to the community when you're done with it. :thumbsup:

Share this post


Link to post
Share on other sites

Well, try this:

 

Find in ./ajax/css/ajaxManager.css

#placeorder_area {
width: 100%; float: right; padding: 5px; text-align: left;
}
#payment_area {
width: 49%; float: right;
}
#shipping_area {
width: 50%; float: left;
}
#totals_area{
float: right; width: 100%; border-top: 1px solid black;
}
#products_area {
float: left; width: 100%;
}

 

Replace it with something like this (just an example):

#placeorder_area {
width: 100%; float: right; padding: 5px; text-align: left;
}
#payment_area {
width: 100%; float: right;
}
#shipping_area {
width: 100%; float: right;
}
#totals_area{
float: right; width: 100%; border-top: 1px solid black;
}
#products_area {
float: left; width: 100%;
}
#ajaxManager .ajaxContainer {
width: 100% !important;
float: left !important;
}
#ajaxManager .infoBoxContents {
float: none !important;
}
#ajaxManager p {
width: auto !important;
}

 

Then in ./ajax/classes/ajaxManagerTest.class.php

 

Find around line 2007:

 <p style="margin-top:0px;"><?php echo tep_address_label($customer_id, $sendto, true, ' ', '<br>'); ?></p>
</div>
</div>
</div>

 

Replace with:

 <p style="margin-top:0px;"><?php echo tep_address_label($customer_id, $sendto, true, ' ', '<br>'); ?></p>
</div>
<div style="clear: both;"></div>
</div>
</div>

 

 

I just wanted to show you how it works, it's up to you to make it look good. Don't forget to upload it to the community when you're done with it. :thumbsup:

 

thanks

 

what about the multiple "continue" buttons that seem to be shown under each column of boxes?

 

under the address box, there is a continue, and then under the payment also.

 

i would like if possible to have everything in a nice numbered format like you see on most modern checkouts.

Share this post


Link to post
Share on other sites

thanks

 

what about the multiple "continue" buttons that seem to be shown under each column of boxes?

 

under the address box, there is a continue, and then under the payment also.

 

i would like if possible to have everything in a nice numbered format like you see on most modern checkouts.

 

I don't understand what you mean by numbered?

 

Sometimes the Payment methods is based on the selected shipping option and vice versa, at least it wouldn't work for me to have just a single purchase button.

If you don't need all the functionality perhaps it would be better to use something simpler, like a single PHP page that loads all your payment/shipping modules and the customer can just choose what he/she want and the click submit?

 

If so, then I think it will be easier for you to modify & use any of the other Add-Ons because you don't need Ajax for that.

Share this post


Link to post
Share on other sites

Hi, I am trying to install on localhost and found this error.

 

javascript_validation(); ?>

Fast Checkout

 

 

Parse error: syntax error, unexpected 'else' (T_ELSE), expecting function (T_FUNCTION) in D:\xampp\htdocs\projects\oscommerce\catalog233\ajax\classes\ajaxManagerTest.class.php on line 1320

 

Please check the attachment.

Thanks.


Lachit Kashyap

Share this post


Link to post
Share on other sites

Hi, thanks for this good contribution.

 

I see a bug in create account section, when customer select country (united states) state selection not working properly.

Error message, Please select a state from the States pull down menu.

 

My testing demo: http://goo.gl/hrtDW1

Can you tell me how do I fix the state selection issue.

 

Thanks an advance.

Sorry for my bad English.


Lachit Kashyap

Share this post


Link to post
Share on other sites

yes, i just tried your website and you are correct.

 

if you select USA as your country,

 

there is no automatic reload of the "state" field, so you have to type it in by hand.

 

But then when you click continue, it reloads the page, except now the state field has all the states in dropdown option and that error "Please select a state from the States pull down menu." always shows and wont let you continue.

 

seems like a big bug.

Share this post


Link to post
Share on other sites

Hi, I am trying to install on localhost and found this error.

 

javascript_validation(); ?>

Fast Checkout

 

 

Parse error: syntax error, unexpected 'else' (T_ELSE), expecting function (T_FUNCTION) in D:\xampp\htdocs\projects\oscommerce\catalog233\ajax\classes\ajaxManagerTest.class.php on line 1320

 

Please check the attachment.

Thanks.

 

In ajaxManagerTest.class.php find all occurrences of <? and change them to <?php

This should fix it.

Share this post


Link to post
Share on other sites

Hi, thanks for this good contribution.

 

I see a bug in create account section, when customer select country (united states) state selection not working properly.

Error message, Please select a state from the States pull down menu.

 

My testing demo: http://goo.gl/hrtDW1

Can you tell me how do I fix the state selection issue.

 

Thanks an advance.

Sorry for my bad English.

 

I'm trying to understand what you mean, since I'm not using states myself I don't really know what's supposed to happen.

 

Should the State/Province have a dropdown after the customer choose his/her country?

 

I can't reproduce this error on my own server, I just get an input field for the state and no errors when submitting the form.

 

You could try replacing this code:

if (ACCOUNT_STATE == 'true') {
$this->getAndPrepare('state', $get, $state);
$zone_id = false;
}

With:

if (ACCOUNT_STATE == 'true') {
$this->getAndPrepare('state', $get, $state);
if (isset($HTTP_POST_VARS['zone_id'])) {
 $this->getAndPrepare('zone_id', $get, $zone_id);
} else {
 $zone_id = false;
}
}

 

 

There are several more bugs that I have found and fixed on my own server, as well as performance updates.

When I have the time and inclination I will upload a new release with these changes applied.

Share this post


Link to post
Share on other sites

Hello,

 

I'm installing both addons and I think that I get it ready.

 

Thanks for this contributions :)

 

Will be possible to show a dialog box when you click to remove a product in shopping_cart or box_shoppin_cart? On index.php it's show a dialog box.

 

Thanks in advance :)

Share this post


Link to post
Share on other sites

I can't edit my previous post :(

 

In shopping_cart.php finding this:

 

'<span class="delete" onclick="return($(this).cartRemoveAction(\''.$products[$i]['id'].'\'));" style="visibility:hidden; cursor: pointer;" rel="' . $products[$i]['id'] . '">'

 

And replacing by this:

 

'<span class="delete" onclick="return($(this).cartRemove());" style="visibility:hidden; cursor: pointer;" rel="' . $products[$i]['id'] . '">'

 

Shows a confirmation dialog box.

 

Now I'm looking to make the same in ajax_checkout.php

 

Bye!!

Share this post


Link to post
Share on other sites

I can't edit my previous post :(

 

In shopping_cart.php finding this:

 

'<span class="delete" onclick="return($(this).cartRemoveAction(\''.$products[$i]['id'].'\'));" style="visibility:hidden; cursor: pointer;" rel="' . $products[$i]['id'] . '">'

 

And replacing by this:

 

'<span class="delete" onclick="return($(this).cartRemove());" style="visibility:hidden; cursor: pointer;" rel="' . $products[$i]['id'] . '">'

 

Shows a confirmation dialog box.

 

Now I'm looking to make the same in ajax_checkout.php

 

Bye!!

 

Glad you solved it!

If you update to the newest release of jQuery Shopping cart, then all you need to do is change the class from "cart-delete" to "delete".

 

With the "delete" class you will get the dialog and with "cart-delete" the product will be removed instantly.

Share this post


Link to post
Share on other sites

Thanks for the update and the fix, it's works perfectly :)

 

Will be possible to make the same in ajax_checkout.php ? I don't have idea how I can do it :(

 

Thanks in advance.

Share this post


Link to post
Share on other sites

Thanks for the update and the fix, it's works perfectly :)

 

Will be possible to make the same in ajax_checkout.php ? I don't have idea how I can do it :(

 

Thanks in advance.

 

In ./ajax/classes/ajaxManagerTest.class.php

Find:

$info_box_contents[$cur_row][] = array('align' => 'center',
'params' => 'class="productListing-data" valign="middle"',
'text' => tep_draw_checkbox_field('cart_delete[]', $order->products[$i]['id'], false, 'style="display:none;"') .
'<span class="cart-remove" style="visibility:visible;" onclick="cartremove(\''.$order->products[$i]['id'].'\');" rel="' . $order->products[$i]['id'] . '">'
. tep_image(DIR_WS_ICONS . 'cancel.png', TEXT_REMOVE) . '</span>' .
'<span style="display:none;" id="pn-' . $order->products[$i]['id'] . '">' .
'<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $order->products[$i]['id']) . '">' . $order->products[$i]['name'] . '</a></span>') ;

Replace with:

$info_box_contents[$cur_row][] = array('align' => 'center',
'params' => 'class="productListing-data" valign="middle"',
'text' => tep_draw_checkbox_field('cart_delete[]', $order->products[$i]['id'], false, 'style="display:none;"') .
'<span class="delete" style="visibility:visible;" rel="' . $order->products[$i]['id'] . '">'
. tep_image(DIR_WS_ICONS . 'cancel.png', TEXT_REMOVE) . '</span>' .
'<span style="display:none;" id="pn-' . $order->products[$i]['id'] . '">' .
'<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $order->products[$i]['id']) . '">' . $order->products[$i]['name'] . '</a></span>') ;

Share this post


Link to post
Share on other sites

Perfect!

 

Tonight I was tired and don't tried with the correct class :(

 

About the new update, is more fast than previous :) but en ajax_checkout.php when you push on minus or more button, the shopping box delete his products and shows empty. The quantity update is made, but shopping_box don't show any item.

 

Thanks for all :)

Share this post


Link to post
Share on other sites

Yeah, I found a bug that prevented account creation so I made a temporary fix in javascript that reloads the page to get a new session. However, I have it working for me now so you can try to fix it with this code:

 

In ./ajax/classes/ajaxManagerTest.class.php, Find this code around line 2723

if (SESSION_RECREATE == 'True') {
tep_session_recreate();
}

Replace it with this code:

if (SESSION_RECREATE == 'True') {
tep_session_recreate();
$amSessionVar = tep_session_name().'='.tep_session_id();
echo tep_draw_hidden_field('session_var', $amSessionVar, 'id="session_var"');
}

 

Find this code in ./ajax/javascript/ajaxManager.js around line 63

var arRequestString = new Array;

Replace it with this code:

var arRequestString = new Array;
var url = 'ajax/ajaxManager.php';
if (getElement('session_var') != null) var sessionId = getValue('session_var');

 

Comment or remove the following code, located around line 240 and line 342:

location.reload();

 

Report back if this worked. Also, make sure that Recreate Session is set to true in your admin (Configuration => Sessions).

I'm trying to understand what you mean, since I'm not using states myself I don't really know what's supposed to happen.

 

Should the State/Province have a dropdown after the customer choose his/her country?

 

I can't reproduce this error on my own server, I just get an input field for the state and no errors when submitting the form.

 

You could try replacing this code:

if (ACCOUNT_STATE == 'true') {
$this->getAndPrepare('state', $get, $state);
$zone_id = false;
}

With:

if (ACCOUNT_STATE == 'true') {
$this->getAndPrepare('state', $get, $state);
if (isset($HTTP_POST_VARS['zone_id'])) {
 $this->getAndPrepare('zone_id', $get, $zone_id);
} else {
 $zone_id = false;
}
}

 

 

There are several more bugs that I have found and fixed on my own server, as well as performance updates.

When I have the time and inclination I will upload a new release with these changes applied.

 

I need to apply this two bugfix to make create account work, thanks for this patches :)

Share this post


Link to post
Share on other sites

Cosmetic fix:

 

In ./ajax/classes/ajaxManagerTest.class.php

Find:

  <p style="float:right;"><?php echo TEXT_CREATE_NEW_PAYMENT_ADDRESS; ?></p>
  <div><?php require('ajax/includes/' . 'checkout_new_address.php'); ?></div>

And replace with:

  <p style="float:right;"><?php echo TEXT_CREATE_NEW_PAYMENT_ADDRESS; ?></p>
  <div style="clear: both;"></div>
  <div><?php require('ajax/includes/' . 'checkout_new_address.php'); ?></div>

And find:

  <p style="float:right;"><?php echo TEXT_CREATE_NEW_SHIPPING_ADDRESS; ?></p>
  <div><?php require('ajax/includes/' . 'checkout_new_address.php'); ?></div>

Replace with:

  <p style="float:right;"><?php echo TEXT_CREATE_NEW_SHIPPING_ADDRESS; ?></p>
  <div style="clear: both;"></div>
  <div><?php require('ajax/includes/' . 'checkout_new_address.php'); ?></div>

;)

Share this post


Link to post
Share on other sites

Perfect!

 

Tonight I was tired and don't tried with the correct class :(

 

About the new update, is more fast than previous :) but en ajax_checkout.php when you push on minus or more button, the shopping box delete his products and shows empty. The quantity update is made, but shopping_box don't show any item.

 

Thanks for all :)

 

Haha, I've been up countless nights to figure this code out too so I know how that feels like! :D

 

In order to fix this, you can use my current code. Watch out, however, as I might have done modifications that will introduce new problems for you. I would guess that the "free shipping" of my ajaxmanager.js might need to be replaced with the code you have now.

 

NOTE: As I wrote further down, I have tried to revert my specific modifications from the ajaxManager.js so it might work as it is. Otherwise, just compare the sections that don't work with your old file and you'll figure it out.

 

This update can & probably should be applied to everyone using this Add-On, I don't know when I'll have time to upload a proper update so will have to do until then.

 

First in ./ajax/classes/ajaxManagerTest.class.php

Find:

$info_box_contents[$cur_row][] = array('params' => 'class="cart-qty" ',
'text' =>
'<span onclick="updateqty(\'moins\', \''.$order->products[$i]['id'].'\');" class="" style="visibility:visible;" rel="' . $order->products[$i]['id'] . '">' . tep_image(DIR_WS_ICONS . 'moins.png') . '</span>' .
tep_draw_input_field('cart_quantity[]', $order->products[$i]['qty'], 'size="4" id="pl' . $order->products[$i]['id'] . '"' ) . tep_draw_hidden_field('products_id[]', $order->products[$i]['id']) .
'<span onclick="updateqty(\'plus\', \''.$order->products[$i]['id'].'\');" class="" style="visibility:visible;" rel="' . $order->products[$i]['id'] . '">' . tep_image(DIR_WS_ICONS . 'plus.png') . '</span>'
);

Replace with:

$info_box_contents[$cur_row][] = array('params' => 'class="cart-qty" ',
'text' =>
'<span class="update-qty moins" style="cursor: pointer;" rel="' . $order->products[$i]['id'] . '">' . tep_image(DIR_WS_ICONS . 'moins.png') . '</span>' .
tep_draw_input_field('cart_quantity[]', $order->products[$i]['qty'], 'size="4" id="pl' . $order->products[$i]['id'] . '"' ) . tep_draw_hidden_field('products_id[]', $order->products[$i]['id']) .
'<span class="update-qty plus" style="cursor: pointer;" rel="' . $order->products[$i]['id'] . '">' . tep_image(DIR_WS_ICONS . 'plus.png') . '</span>'
);

Find:

$info_box_contents[$cur_row][] = array('align' => 'center',
'params' => 'class="productListing-data" valign="middle"',
'text' => tep_draw_checkbox_field('cart_delete[]', $order->products[$i]['id'], false, 'style="display:none;"') .
'<span class="cart-remove" style="visibility:visible;" onclick="cartremove(\''.$order->products[$i]['id'].'\');" rel="' . $order->products[$i]['id'] . '">'
. tep_image(DIR_WS_ICONS . 'cancel.png', TEXT_REMOVE) . '</span>' .
'<span style="display:none;" id="pn-' . $order->products[$i]['id'] . '">' .
'<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $order->products[$i]['id']) . '">' . $order->products[$i]['name'] . '</a></span>') ;

Replace with:

$info_box_contents[$cur_row][] = array('align' => 'center',
'params' => 'class="productListing-data" valign="middle"',
'text' => tep_draw_checkbox_field('cart_delete[]', $order->products[$i]['id'], false, 'style="display:none;"') .
'<span class="cart-delete" style="visibility:visible; cursor: pointer;" rel="' . $order->products[$i]['id'] . '">'
. tep_image(DIR_WS_ICONS . 'cancel.png', TEXT_REMOVE) . '</span>' .
'<span style="display:none;" id="pn-' . $order->products[$i]['id'] . '">' .
'<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $order->products[$i]['id']) . '">' . $order->products[$i]['name'] . '</a></span>') ;

 

While we're at it, this will fix the session bug when creating account and the page reloads, it will also provide quick fix for other bugs:

 

Find:

// load the before_process function from the payment modules
$_resp = $payment_modules->before_process();
if ($_resp['error'] == false) {
if ($cart->count_contents() < 1) {
 include(DIR_WS_LANGUAGES . $language . '/' . FILENAME_SHOPPING_CART);
 $_resp = array('error'=>true, 'message'=> TEXT_CART_EMPTY);
}
}

Add this code below:

// Stock Check
 $any_out_of_stock = false;
 if (STOCK_CHECK == 'true') {
 for ($i=0, $n=sizeof($order->products); $i<$n; $i++) {
	 if (tep_check_stock($order->products[$i]['id'], $order->products[$i]['qty'])) {
	 $any_out_of_stock = true;
	 }
 }
 // Out of Stock
 if ( (STOCK_ALLOW_CHECKOUT != 'true') && ($any_out_of_stock == true) ) {
 include(DIR_WS_LANGUAGES . $language . '/' . FILENAME_SHOPPING_CART);
 $_resp = array('error'=>true, 'message'=> OUT_OF_STOCK_CANT_CHECKOUT);
	 //tep_redirect(tep_href_link(FILENAME_SHOPPING_CART));
 }
 }

 

Find:

if (SESSION_RECREATE == 'True') {
tep_session_recreate();
}
$customer_first_name = $firstname;
$customer_default_address_id = $address_id;
$customer_country_id = $country;
$customer_zone_id = $zone_id;
ajaxSessionRegister('customer_id',$customer_id);
ajaxSessionRegister('customer_first_name',$customer_first_name);
ajaxSessionRegister('customer_default_address_id',$customer_default_address_id);
ajaxSessionRegister('customer_country_id',$customer_country_id);
ajaxSessionRegister('customer_zone_id',$customer_zone_id);

Replace with:

if (SESSION_RECREATE == 'True') {
tep_session_recreate();
$amSessionVar = tep_session_name().'='.tep_session_id();
echo tep_draw_hidden_field('session_var', $amSessionVar, 'id="session_var"');
}
$customer_first_name = $firstname;
$customer_default_address_id = $address_id;
$customer_country_id = $country;
$customer_zone_id = $zone_id;
ajaxSessionRegister('customer_id',$customer_id);
ajaxSessionRegister('customer_first_name',$customer_first_name);
ajaxSessionRegister('customer_default_address_id',$customer_default_address_id);
ajaxSessionRegister('customer_country_id',$customer_country_id);
ajaxSessionRegister('customer_zone_id',$customer_zone_id);

 

I tried to find and "reverse" the modifications to ajaxManager.js that are specific to my site, hopefully, you can just replace your ajaxManager.js with this code:

/*
AJAX Checkout for OsCommerce
Advance Software

Copyright (c) 2007 Advance Software
*/
$('body').on('click', '.update-qty', function(){
productID = $(this).attr('rel') ;
val = parseInt( $('input[id="pl' + productID + '"][name=\"cart_quantity[]\"]').val() ) ;
action = $(this).attr('class').split(' ').slice(-1) ;
if ( action == 'plus' )
{
val = val + 1 ;
action = 1;
}
else if ( action == 'moins' )
{
if ( val <= 0 ) return(false) ;
val = val - 1 ;
action = -1;
}
else
{
return(false) ;
}
return($(this).updateqty(productID, action, val));
return false;
});
var placeHolderDiv;
var url = 'ajax/ajaxManager.php';
var ajaxRequester = new Requester();
function ajaxManagerInit() {
if(ajaxRequester.isAvailable())
ajaxRefresh(true);
return(false);
}
function getElement(id) {
return document.getElementById(id);
return(false);
}
function getDropDownValue(id) {
return getElement(id).value;
return(false);
}
function getValue(id) {
return getElement(id).value;
return(false);
}
//------------------------------------------------------------------<< Common Stuff
function ajaxSendRequest(requestString,functionName, refresh, target, async) {
var arRequestString = new Array;
var url = 'ajax/ajaxManager.php';
if (getElement('session_var') != null) var sessionId = getValue('session_var');
if('' != requestString)
arRequestString.push(requestString);
if('' != productsId)
arRequestString.push('products_id='+productsId);
if('' != pageAction)
arRequestString.push('pageAction='+pageAction);
if('' != sessionId)
arRequestString.push(sessionId);
if(refresh == false)
ajaxRequester.setAction(ajaxEmpty);
else
ajaxRequester.setAction((((null == functionName) || ('' == functionName)) ? ajaxUpdateContent : functionName));
if(null == target) {
ajaxRequester.setTarget('ajaxManager');
}
else {
ajaxRequester.setTarget(target);
arRequestString.push('target='+target);
}

//show loading..
if (target == null)
var objBody = document.getElementById('ajaxManager');
else
var objBody = document.getElementById(target);
var objOverlay = document.createElement("div");
objOverlay.setAttribute('id','overlay');
objOverlay.style.position = 'absolute';
objOverlay.style.textAlign = 'center';
objOverlay.style.verticalAlign = 'middle';
objOverlay.style.width = objBody.clientWidth;
objOverlay.style.height = objBody.clientHeight;
objBody.insertBefore(objOverlay, objBody.firstChild);
objOverlay.style.display = 'block';
document.getElementById("overlay").innerHTML = '<table border=0 width=100% height=100%><tr><td align="center"><img src="images/loading.gif"></td></tr></table>';
//eof show loading
if (getElement('buttonchangeShippingAddress') != null) getElement('buttonchangeShippingAddress').disabled = true;
if (getElement('buttonchangePaymentAddress') != null) getElement('buttonchangePaymentAddress').disabled = true;
if (getElement('buttonselectPayment') != null) getElement('buttonselectPayment').disabled = true;
if (getElement('buttonselectShipping') != null) getElement('buttonselectShipping').disabled = true;
if (getElement('buttonselectPaymentAddress') != null) getElement('buttonselectPaymentAddress').disabled = true;
if (getElement('buttonselectShippingAddress') != null) getElement('buttonselectShippingAddress').disabled = true;
if (getElement('buttonPlaceOrder') != null) getElement('buttonPlaceOrder').disabled = true;

requestString = arRequestString.join('&');
ajaxRequester.loadURL(url, requestString, async);
return false;
}
function ajaxEmpty(){}
function ajaxReportError(request) {
alert('Sorry. There was an error.');
return(false);
}
function ajaxRefresh(bolFirstCall) {
var rString = (!bolFirstCall) ? 'ajaxAction=refresh' : '';
ajaxSendRequest(rString);
return false;
}
function ajaxUpdateContent(id) {
getElement(ajaxRequester.getTarget()).innerHTML = ajaxRequester.getText();
if (getElement('buttonchangeShippingAddress') != null) getElement('buttonchangeShippingAddress').disabled = false;
if (getElement('buttonchangePaymentAddress') != null) getElement('buttonchangePaymentAddress').disabled = false;
if (getElement('buttonselectPayment') != null) getElement('buttonselectPayment').disabled = false;
if (getElement('buttonselectShipping') != null) getElement('buttonselectShipping').disabled = false;
if (getElement('buttonselectPaymentAddress') != null) getElement('buttonselectPaymentAddress').disabled = false;
if (getElement('buttonselectShippingAddress') != null) getElement('buttonselectShippingAddress').disabled = false;
if (getElement('buttonPlaceOrder') != null) getElement('buttonPlaceOrder').disabled = false;

return(false);
}
function ajaxUpdateContentMulti(id) {
var result = ajaxRequester.getText();
//split string with </divresult> word
arr = result.split('</divresult>');
for (i=0; i<arr.length; i++) {
try {
//get div name
regexp = /<divresult name=\"(\w+)\">/;
var divelement = arr[i].match(regexp)[1];
//get div content
var divresult = arr[i].replace(regexp,"") ;
getElement(divelement).innerHTML = divresult;
}
catch (error) {}
}
if (getElement('buttonchangeShippingAddress') != null) getElement('buttonchangeShippingAddress').disabled = false;
if (getElement('buttonchangePaymentAddress') = null) getElement('buttonchangePaymentAddress').disabled = false;
if (getElement('buttonselectPayment') != null) getElement('buttonselectPayment').disabled = false;
if (getElement('buttonselectShipping') != null) getElement('buttonselectShipping').disabled = false;
if (getElement('buttonselectPaymentAddress') != null) getElement('buttonselectPaymentAddress').disabled = false;
if (getElement('buttonselectShippingAddress') != null) getElement('buttonselectShippingAddress').disabled = false;
if (getElement('buttonPlaceOrder') != null) getElement('buttonPlaceOrder').disabled = false;

return(false);
}
//------------------------------------------------------------------<< page Actions
function ajaxRefreshShipping(async) {
ajaxSendRequest('ajaxAction=showShipping',ajaxUpdateContentMulti,true,'shipping_area', async);
return false;
}
function ajaxRefreshPayment(async) {
ajaxSendRequest('ajaxAction=showPayment',ajaxUpdateContentMulti,true,'payment_area', async);
return false;
}
function ajaxRefreshProducts(async) {
ajaxSendRequest('ajaxAction=showProducts','',true,'products_area', false, async);
return false;
}
function ajaxRefreshTotals(async) {
ajaxSendRequest('ajaxAction=showTotals','',true,'totals_area', async);
return false;
}
function ajaxSetInterfaceLanguage(languageId) {
ajaxSendRequest('ajaxAction=setInterfaceLanguage&language_id='+languageId);
return false;
}
function ajaxSetSession() {
var session_var = getValue('session_var');
ajaxSendRequest('ajaxAction=createSession&session_var='+session_var,'',true,'test_div');
return false;
}
function ajaxShowChangeAddress()
{
$("#TheSubmitButton").hide();
$("#TheDisabledButton").hide();
ajaxSendRequest('ajaxAction=showChangeAddress','',true,'shipping_area');
return false;
}
function ajaxShowChangePaymentAddress()
{
ajaxSendRequest('ajaxAction=showChangePaymentAddress','',true,'payment_area');
return false;
}
function ajaxPerformLogin() {
var login_email_address = getValue('login_email_address');
var login_password = getValue('login_password');

$('#logoffButton').show();
$('.noDisplay').show();

ajaxSendRequest('ajaxAction=PerformLogin&email_address='+login_email_address+'&password='+login_password,ajaxUpdateContentMulti,true,'payment_area', false);
// location.reload();
return false;
}
function ajaxPerformPlaceOrder() {
ajaxSendRequest('ajaxAction=PerformPlaceOrder',ajaxUpdateContentMulti,true,'placeorder_area');
return(false);
}
function ajaxPerformShippingSelection() {
submitted = false;
if (getElement('buttonselectPayment') == null) {
$("#agreeForm").fadeIn(600);
}
if (getElement('shipping_'+selected_shipping) != null)
{
var shipping = getValue('shipping_'+selected_shipping);
}
else
{
var shipping = getValue('shipping');
}
ajaxSendRequest('ajaxAction=PerformShippingSelection&shipping='+shipping,ajaxUpdateContentMulti,true,'shipping_area');
return false;
}

function ajaxPerformPaymentSelection() {
submitted = false;

if (getElement('buttonselectPayment') == null || getElement('buttonselectShipping') == null) {
$("#agreeForm").fadeIn(300);
}
additional_fields = '';
if (selected_payment >= 0)
{
var payment = getValue('payment_'+selected_payment);
}
else
{
var payment = getValue('payment');
}
if (check_form() == true)
{
ajaxSendRequest('ajaxAction=PerformPaymentSelection&payment='+payment+additional_fields,ajaxUpdateContentMulti,true,'payment_area');
}
else return false;
return false;
}
function ajaxPerformCreateAccount()
{
submitted = false;
if (check_create_account()==true)
{
var email_address = getValue('email_address');
if (getElement('gender') != null) var gender = getValue('gender');
var firstname = getValue('firstname');
var lastname = getValue('lastname');
if (getElement('dob') != null) var dob = getValue('dob');
if (getElement('company') != null) var company = getValue('company');
var street_address = getValue('street_address');
if (getElement('suburb') != null) var suburb = getValue('suburb');
var postcode = getValue('postcode');
var city = getValue('city');
if (getElement('state') != null) var state = getValue('state');
var country = getValue('country');
var telephone = getValue('telephone');
var fax = getValue('fax');
var newsletter = getValue('newsletter');
var password = getValue('password');
var confirmation = getValue('confirmation');
ajaxSendRequest('ajaxAction=PerformCreateAccount'
+'&email_address='+email_address
+'&gender='+gender
+'&firstname='+firstname
+'&lastname='+lastname
+'&dob='+dob
+'&company='+company
+'&street_address='+street_address
+'&suburb='+suburb
+'&postcode='+postcode
+'&city='+city
+'&state='+state
+'&country='+country
+'&telephone='+telephone
+'&fax='+fax
+'&newsletter='+newsletter
+'&password='+password
+'&confirmation='+confirmation
//);
, ajaxUpdateContentMulti, true, 'shipping_area', false);
//location.reload();
$('#logoffButton').show();
$('.noDisplay').show();
} else return false;
return false;
}
function ajaxPerformShippingAddress()
{
submitted = false;
if (getElement('gender') != null) var gender = getValue('gender');
if (getElement('firstname') != null) var firstname = getValue('firstname');
if (getElement('lastname') != null) var lastname = getValue('lastname');
if (getElement('company') != null) var company = getValue('company');
if (getElement('street_address') != null) var street_address = getValue('street_address');
if (getElement('suburb') != null) var suburb = getValue('suburb');
if (getElement('postcode') != null) var postcode = getValue('postcode');
if (getElement('city') != null) var city = getValue('city');
if (getElement('state') != null) var state = getValue('state');
if (getElement('country') != null) var country = getValue('country');
if (firstname!= null && lastname!=null && street_address!=null && firstname!='' && lastname!='' && street_address!='')
{
if (check_form_address()==true)
{
ajaxSendRequest('ajaxAction=PerformShippingAddress'
+'&gender='+gender
+'&firstname='+firstname
+'&lastname='+lastname
+'&company='+company
+'&street_address='+street_address
+'&suburb='+suburb
+'&postcode='+postcode
+'&city='+city
+'&state='+state
+'&country='+country
//);
,ajaxUpdateContentMulti,true,'shipping_area');
}
else return false;
}
else
{
if (getElement('address_'+selected_address) != null) var address = getValue('address_'+selected_address);
ajaxSendRequest('ajaxAction=PerformShippingAddressSelection'
+'&address='+address
,ajaxUpdateContentMulti,true,'shipping_area');
}

return(false);
}
function ajaxPerformPaymentAddress()
{
submitted = false;
if (getElement('gender') != null) var gender = getValue('gender');
if (getElement('firstname') != null) var firstname = getValue('firstname');
if (getElement('lastname') != null) var lastname = getValue('lastname');
if (getElement('company') != null) var company = getValue('company');
if (getElement('street_address') != null) var street_address = getValue('street_address');
if (getElement('suburb') != null) var suburb = getValue('suburb');
if (getElement('postcode') != null) var postcode = getValue('postcode');
if (getElement('city') != null) var city = getValue('city');
if (getElement('state') != null) var state = getValue('state');
if (getElement('country') != null) var country = getValue('country');
if (firstname!= null && lastname!=null && street_address!=null && firstname!='' && lastname!='' && street_address!='')
{
if (check_form_address()==true)
{
ajaxSendRequest('ajaxAction=PerformPaymentAddress'
+'&gender='+gender
+'&firstname='+firstname
+'&lastname='+lastname
+'&company='+company
+'&street_address='+street_address
+'&suburb='+suburb
+'&postcode='+postcode
+'&city='+city
+'&state='+state
+'&country='+country
//);
,ajaxUpdateContentMulti,true,'payment_area');
}
else return false;
}
else
{
if (getElement('payment_address_'+selected_payment_address) != null) var address = getValue('payment_address_'+selected_payment_address);
ajaxSendRequest('ajaxAction=PerformPaymentAddressSelection'
+'&address='+address
,ajaxUpdateContentMulti,true,'payment_area');
}

return(false);
}
function check_agree(title, text) {
if ($("#TermsAgree").prop("checked")){
$("#TheSubmitButton").hide();
$('#order_submitted').fadeIn(300);
if (getElement('comments') != null) var comments = getValue('comments');
ajaxSendRequest('ajaxAction=PerformPlaceOrder'+'&comments='+comments,ajaxUpdateContentMulti,true,'placeorder_area');

// Reset headercart
var parentHeader = $('#headercart').parent();
$('#headercart').remove();
parentHeader.append( '<span id="headercart"></span>' ) ;

// Reset carrt
$('#boxcart-content').find('li').each(function() {
$(this).remove();
});
$(".boxcartTotal").hide();
$('#boxcart-content').html('<li style="font-size:11px; float:right;">' + $('#boxcart-text-empty').html() + '</li>') ;
} else {
return $("<div class='dialog' title='" + title + "'><p>" + text + "</p></div>")
.dialog({
resizable: false,
modal: true,
draggable: false,
open: function(event, ui) {
 $(this).parent()
 .css('position', 'fixed')
 .css('top', '30%');
$(this).parents(".ui-dialog:first").find(".ui-icon-closethick")
 .css('top', '0')
 .css('left', '0');
},
buttons: {
Cancel: function() {
 $( this ).dialog( "close" );
}
}
});
}

return(false);
}
function check_agree_create(title, text) {
return $("<div class='dialog' title='" + title + "'><p>" + text + "</p></div>")
.dialog({
resizable: false,
modal: true,
draggable: false,
open: function(event, ui) {
 $(this).parent()
.css('position', 'fixed')
.css('top', '30%');
$(this).parents(".ui-dialog:first").find(".ui-icon-closethick")
.css('top', '0')
.css('left', '0');
},
buttons: {
Cancel: function() {
$( this ).dialog( "close" );
}
}
});

return(false);
}
function formatString(string)
{
if (/^[a-ö].+$/.test(string))
var string = string.charAt(0).toUpperCase() + string.slice(1);
return string;

return(false);
}
function validateString(name) {
if(name == 'firstname') {
document.getElementById("firstname").value =
formatString(document.getElementById("firstname").value) + "\n";
}
if(name == 'lastname') {
document.getElementById("lastname").value =
formatString(document.getElementById("lastname").value) + "\n";
}
if(name == 'company') {
document.getElementById("company").value =
formatString(document.getElementById("company").value) + "\n";
}
if(name == 'street_address') {
document.getElementById("street_address").value =
formatString(document.getElementById("street_address").value) + "\n";
}
if(name == 'suburb') {
document.getElementById("suburb").value =
formatString(document.getElementById("suburb").value) + "\n";
}
if(name == 'city') {
document.getElementById("city").value =
formatString(document.getElementById("city").value) + "\n";
}
if(name == 'state') {
document.getElementById("state").value =
formatString(document.getElementById("state").value) + "\n";
}

return(false);
}

function ajaxPerformShippingRefresh() {
submitted = false;
var orderTotalNewValue = parseFloat(getValue('orderTotalNewValue'));
var orderTotalOldValue = parseFloat(getValue('orderTotalOldValue'));

if (getElement('shippingselected') != null)
{
var shipping = getValue('shippingselected');
if (getElement('freeShippingOver') != null) {
var freeShippingOver = parseFloat(getValue('freeShippingOver'));
if (orderTotalOldValue > freeShippingOver && orderTotalNewValue < freeShippingOver) {
 ajaxSendRequest('ajaxAction=showShipping',ajaxUpdateContentMulti,true,'shipping_area', false);
 ajaxRefreshTotals();
} else if ( orderTotalNewValue > freeShippingOver ) {
 ajaxSendRequest('ajaxAction=PerformShippingSelection&shipping=free_free',ajaxUpdateContentMulti,true,'shipping_area');
} else {
 ajaxSendRequest('ajaxAction=PerformShippingSelection&shipping='+shipping,ajaxUpdateContentMulti,true,'totals_area');
}
} else {
ajaxSendRequest('ajaxAction=PerformShippingSelection&shipping='+shipping,ajaxUpdateContentMulti,true,'totals_area');
}
} else {
ajaxRefreshShipping(false);
ajaxRefreshTotals();
}
return false;
}

Share this post


Link to post
Share on other sites

Some additional Info for those that struggle with modifying the code for this Add-On:

 

This code:

$this->getAndPrepare('payment', $get, $payment);

Equals:

$payment = tep_db_prepare_input($HTTP_POST_VARS['payment']);

 

Also, for those of you that have updated your site from MySQL to MySQLi (which you should!)

Instructions:

https://github.com/osCommerce/oscommerce2/commit/caa15f7a4619686ab2a32d963d92341a8642851d

 

The instructions doesn't mentioning setting the correct character encoding, to do this, in:

./includes/functions/database.php

./admin/includes/functions/database.php

change this code:

$$link = mysqli_connect($server, $username, $password, $database);

TO this:

$$link = mysqli_connect($server, $username, $password, $database);
/* change character set to utf8 */
$$link->set_charset("utf8");

Replacing utf8 with the character encoding your database use.

 

Then specific to get this Add-On working, you need to add:

session_write_close();

Before the closing } on the following functions:

_PerformPlaceOrder, showChangeAddress, performAction2Buffer, showProducts, showTotals, _showPayment, _PerformCreateAccount

 

So for example, the performAction2Buffer function should look like this:

//----------------------------------------------- page actions
function performAction2Buffer($function_name,$param,&$error)
{
ob_start();
$this->$function_name($param, $error);
$result = ob_get_contents();
ob_end_clean();
session_write_close();
return $result;
}

 

Good luck!

Share this post


Link to post
Share on other sites

Thanks for the fix, it works!!

 

I think that this piece of code in ajaxManager.js is from another contribution, yes?

 

$('#logoffButton').show();
$('.noDisplay').show();

 

Thanks for all ;)

Edited by PiLLaO

Share this post


Link to post
Share on other sites

Thanks for the fix, it works!!

 

I think that this piece of code in ajaxManager.js is from another contribution, yes?

 

$('#logoffButton').show();
$('.noDisplay').show();

 

Thanks for all ;)

 

Oh, now when you mention it, I realized that I missed on step!

 

Remove the $('.noDisplay').show(); part but keep the logoffbutton part.

 

In ./includes/header.php find this code:

if (tep_session_is_registered('customer_id')) {
echo tep_draw_button(HEADER_TITLE_LOGOFF, null, tep_href_link(FILENAME_LOGOFF, '', 'SSL'));
}

Replace with:

if (tep_session_is_registered('customer_id')) {
echo tep_draw_button(HEADER_TITLE_LOGOFF, null, tep_href_link(FILENAME_LOGOFF, '', 'SSL'));
} else {
echo '<span id="logoffButton" style="display:none">' . tep_draw_button(HEADER_TITLE_LOGOFF, null, tep_href_link(FILENAME_LOGOFF, '', 'SSL')) . '</span>';
}

 

This will make the logoff button visible when the customer have created a new account or logged in.

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

×