Advance software forum
May 18, 2012, 08:05:08 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
 
   Home   Help Search Login Register  
Pages: [1]   Go Down
  Print  
Author Topic: Ajax checkout - disable shipping address form  (Read 1287 times)
0 Members and 2 Guests are viewing this topic.
kotau
Newbie
*
Offline Offline

Posts: 8


View Profile
« on: February 12, 2009, 12:12:38 PM »

Hi,

I am providing a service instead of a product so I don't need the shipping address or options forms at checkout.

I have set all my products weight to 0 which makes them virtual and have set "ENABLE DOWNLOADS = true".

I have found the location to disable the shipping address form in the /ajax/classes/AjaxManagerTest.class.php file.

However I have found that the system doesn't like not having the shipping rates disabled as it cannot proceed to the and will not respond to the virtual product type by not showing the shipping forms.

So, I decided to add a new function to load both sides of the page at the same time. I will update this with more details as I get them into place...

/ajax/javascript/ajaxManager.js

Add this function around line 216:
Code:
function ajaxPerformDualSelection(){
 
var shipping = getValue('shipping');
additional_fields = '';
if (selected_payment >= 0)
{
  var payment = getValue('payment_'+selected_payment);
}
else
{
var payment = getValue('payment');
}
 
if (check_form() == true)
{
if (payment == 'ajax_authorizenet')
{
  //first check if
  ii = 1;
  payment_fields = getElement(payment+ii);   
  while (payment_fields != null) {
additional_fields = additional_fields + '&' + payment_fields.name + '=' + getValue(payment_fields.id);
try {
payment_fields = getElement(payment+ii);
}
catch(err)
{
break;
}
  ii++;
  }
}    
  ajaxSendRequest('ajaxAction=PerformDualSelection&shipping='+shipping+'&payment='+payment+additional_fields,ajaxUpdateContentMulti,true,'shipping_area');  
}
else return false;

return false;
 
}

/ajax/classes/ajaxManagerTest.class.php

Add this to the end of function ajaxManagerTest(&$arrSessionVar)  (line 21)
Code:
    $this->registerPageAction('PerformDualSelection','PerformDualSelection');

add this function after ajaxManagerTest(&$arrSessionVar) around line 54:
Code:
function PerformDualSelection($get)
{


 
    $shipping_error = false;
    $shipping_buffer = $this->performAction2Buffer("_PerformShippingSelection", $get ,$shipping_error);

    echo '<divresult name="shipping_area">'.$shipping_buffer.'</divresult>';

$error = false;
    $buffer = $this->performAction2Buffer("_PerformPaymentSelection", $get ,$error);

    echo '<divresult name="payment_area">'.$buffer.'</divresult>';

    $totals_error = false;
    $totals_buffer = $this->performAction2Buffer("showTotals", $get, $totals_error);
    echo '<divresult name="totals_area">'.$totals_buffer.'</divresult>';


$order_error = false;
    $order_buffer = $this->performAction2Buffer("showPlaceOrder", $get, $order_error);
    echo '<divresult name="placeorder_area">'.$order_buffer.'</divresult>';



}
For testing add modify this line at the bottom of _showPayment() around line  2230:

Code:
       
        <td align="right"><?php echo tep_draw_separator('pixel_trans.gif''100%''10'); ?>
        <input type="button" value="Select and Continue" onClick="ajaxPerformPaymentSelection();"  id="buttonSelectPayment">   
        </td>
to
Code:

        <td align="right">
<?php echo tep_draw_hidden_field('shipping''free_free','id="shipping"'); ?>
<input type="button" value="Select and Continue" onClick="ajaxPerformDualSelection();"  id="buttonSelectPayment">       
        </td>




edit.

I have now fixed the performDualselection() function to work correctly.





Cheers.

« Last Edit: March 31, 2009, 12:49:35 AM by kotau » Logged
Alex
Administrator
Full Member
*****
Offline Offline

Posts: 128


View Profile
« Reply #1 on: March 12, 2009, 07:46:34 AM »

Hey,

I cant say if you have chosen a right way or not. If you feel comfortable to make new functions and work with them, go on.
The placeorder button is showing in some function called like a "showPlaceorder" or something similar, and is shown *only*
if all information is entered and processed correctly: shipping, payment chosen. I guess you will find a sort of *IF* statement pretending
the *place order* button, so you can remove the shipping check and probably it will work.
Logged
kotau
Newbie
*
Offline Offline

Posts: 8


View Profile
« Reply #2 on: March 31, 2009, 12:54:32 AM »

Hi,

I chose not to remove the check for the shipping vars from the place order section as it would make it difficult if I want to sell real products in the future. This way the functionality of the shipping address and method section is still enabled but handled automatically if free shipping is also enabled.


Cheers.
Logged
Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 3.1.1 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!