Jump to content

HuffYk

Members
  • Content count

    29
  • Joined

  • Last visited

Posts posted by HuffYk


  1. you are welcome Dr.Rolex. Thank YOU for this contrib in 1st place :).

     

    Here is small fix for those who would like to use guest account. Problem is that delivery and billing addresses are not initialized in global $order variable and this makes modules which are linked only to specific zone not functional.

     

    here is fix for shipping part

    basically $order variable has to be initialized after $sendto is set (so delivery array in $order is correctly initialized). For guest account $sendto is using $order variable, thats why another "new order" is needed to initialize it correctly

     

    find this code in function _showShipping (file ajaxManagerTest.class.php)

     

    ajaxSessionUnregister("shipping");
    $order = new order;
    if (GUEST_CHECKOUT == 'false' || ( GUEST_CHECKOUT == 'true' && ALLOW_CREATE_ACCOUNT == 'true' && $guest == false)) {
    // if no shipping destination address was selected, use the customers own address as default
    if (!ajaxSessionIsRegistered('sendto')) {
     $sendto = $customer_default_address_id;
     ajaxSessionRegister('sendto',$sendto);
    } else {
     // verify the selected shipping address
     $check_address_query = tep_db_query("select count(*) as total from " . TABLE_ADDRESS_BOOK . " where customers_id = '" . (int)$customer_id . "' and address_book_id = '" . (int)$sendto . "'");
     $check_address = tep_db_fetch_array($check_address_query);
     if ($check_address['total'] != '1') {
     $sendto = $customer_default_address_id;
     if (ajaxSessionIsRegistered('shipping')) ajaxSessionUnregister('shipping');
     }
    }
    } elseif (GUEST_CHECKOUT == 'true') {
    // if no shipping destination address was selected, use the customers own address as default
    if (!ajaxSessionIsRegistered('sendto')) {
     $sendto = $order->customer;
     ajaxSessionRegister('sendto',$sendto);
    }
    }
    

    change to

    ajaxSessionUnregister("shipping");
    if (GUEST_CHECKOUT == 'false' || ( GUEST_CHECKOUT == 'true' && ALLOW_CREATE_ACCOUNT == 'true' && $guest == false)) {
    // if no shipping destination address was selected, use the customers own address as default
    if (!ajaxSessionIsRegistered('sendto')) {
     $sendto = $customer_default_address_id;
     ajaxSessionRegister('sendto',$sendto);
    } else {
     // verify the selected shipping address
     $check_address_query = tep_db_query("select count(*) as total from " . TABLE_ADDRESS_BOOK . " where customers_id = '" . (int)$customer_id . "' and address_book_id = '" . (int)$sendto . "'");
     $check_address = tep_db_fetch_array($check_address_query);
     if ($check_address['total'] != '1') {
     $sendto = $customer_default_address_id;
     if (ajaxSessionIsRegistered('shipping')) ajaxSessionUnregister('shipping');
     }
    }
    } elseif (GUEST_CHECKOUT == 'true') {
    // if no shipping destination address was selected, use the customers own address as default
    if (!ajaxSessionIsRegistered('sendto')) {
     if (!isset($order)) $order = new order;
     $sendto = $order->customer;
     ajaxSessionRegister('sendto',$sendto);
    }
    }
    $order = new order;
    

     

    here is fix for payment part

    similar fix is needed also for payment part. Here it is more tricky. There are payment modules which check not just billing address but also delivery. Thats why both variables has to be set ($sendto and $billto)

     

    find this code in function _showPayment (file ajaxManagerTest.class.php)

    ajaxSessionUnregister("payment");
    if (GUEST_CHECKOUT == 'false' || ( GUEST_CHECKOUT == 'true' && ALLOW_CREATE_ACCOUNT == 'true' && $guest == false)) {
    // if no billing destination address was selected, use the customers own address as default
    if (!ajaxSessionIsRegIstered('billto')) {
     $billto = $customer_default_address_id;
     ajaxSessionRegister('billto',$billto);
    } else {
     // verify the selected billing address
     $check_address_query = tep_db_query("select count(*) as total from " . TABLE_ADDRESS_BOOK . " where customers_id = '" . (int)$customer_id . "' and address_book_id = '" . (int)$billto . "'");
     $check_address = tep_db_fetch_array($check_address_query);
     if ($check_address['total'] != '1') {
     $billto = $customer_default_address_id;
     if (ajaxSessionIsRegistered('payment')) ajaxSessionUnregister('payment');
     }
    }
    } elseif (GUEST_CHECKOUT == 'true') {
    // if no billing destination address was selected, use the customers own address as default
    if (!ajaxSessionIsRegistered('billto')) {
     $billto = $order->customer;
     ajaxSessionRegister('billto',$billto);
    }
    }
    $order = new order;
    

     

    change it to

     

    ajaxSessionUnregister("payment");
    if (GUEST_CHECKOUT == 'false' || ( GUEST_CHECKOUT == 'true' && ALLOW_CREATE_ACCOUNT == 'true' && $guest == false)) {
    // if no billing destination address was selected, use the customers own address as default
    if (!ajaxSessionIsRegIstered('billto')) {
     $billto = $customer_default_address_id;
     ajaxSessionRegister('billto',$billto);
    } else {
     // verify the selected billing address
     $check_address_query = tep_db_query("select count(*) as total from " . TABLE_ADDRESS_BOOK . " where customers_id = '" . (int)$customer_id . "' and address_book_id = '" . (int)$billto . "'");
     $check_address = tep_db_fetch_array($check_address_query);
     if ($check_address['total'] != '1') {
     $billto = $customer_default_address_id;
     if (ajaxSessionIsRegistered('payment')) ajaxSessionUnregister('payment');
     }
    }
    // if no shipping destination address was selected, use the customers own address as default
    if (!ajaxSessionIsRegistered('sendto')) {
     $sendto = $customer_default_address_id;
     ajaxSessionRegister('sendto',$sendto);
    } else {
     // verify the selected shipping address
     $check_address_query = tep_db_query("select count(*) as total from " . TABLE_ADDRESS_BOOK . " where customers_id = '" . (int)$customer_id . "' and address_book_id = '" . (int)$sendto . "'");
     $check_address = tep_db_fetch_array($check_address_query);
     if ($check_address['total'] != '1') {
     $sendto = $customer_default_address_id;
     if (ajaxSessionIsRegistered('shipping')) ajaxSessionUnregister('shipping');
     }
    }
    } elseif (GUEST_CHECKOUT == 'true') {
    if (!isset($order)) $order = new order;
    // if no billing destination address was selected, use the customers own address as default
    if (!ajaxSessionIsRegistered('billto')) {
     $billto = $order->customer;
     ajaxSessionRegister('billto',$billto);
    }
    // if no shipping destination address was selected, use the customers own address as default
    if (!ajaxSessionIsRegistered('sendto')) {
     $sendto = $order->customer;
     ajaxSessionRegister('sendto',$sendto);
    }
    }
    $order = new order;
    

     

    thats it.


  2. I think I found the answer for both questions. Order is defined in file ajax\ajaxManager.php.

     

    If somebody wants to switch login and create account here are steps I did:

     

    file: ajaxManagerTest.class.php

     

    function: showLogin

    change

    echo tep_draw_form('login', tep_href_link('ajax/ajaxManager.php', 'ajaxAction=PerformLogin&&target=payment_area', 'SSL'), 'post', 'id="login_form"', true);
    

    to

    echo tep_draw_form('login', tep_href_link('ajax/ajaxManager.php', 'ajaxAction=PerformLogin&&target=shipping_area', 'SSL'), 'post', 'id="login_form"', true);
    

     

    function: showCreateAccount

    change

    echo tep_draw_form('create_account', tep_href_link('ajax/ajaxManager.php', 'ajaxAction=PerformCreateAccount&&target=shipping_area', 'SSL'), 'post', 'id="create_account"', true) . tep_draw_checkbox_field('guest_account', true, false, 'style="display:none;" id="guest_account"');
    

    to

    echo tep_draw_form('create_account', tep_href_link('ajax/ajaxManager.php', 'ajaxAction=PerformCreateAccount&&target=payment_area', 'SSL'), 'post', 'id="create_account"', true) . tep_draw_checkbox_field('guest_account', true, false, 'style="display:none;" id="guest_account"');
    

     

     

    function: _showShipping

    change line

    if (!ajaxSessionIsRegistered('customer_id')) $this->showCreateAccount('');
    

    to

    if (!tep_session_is_registered('customer_id')) $this->showLogin('');
    

     

    function: _showPayment

    change line

    if (!tep_session_is_registered('customer_id')) $this->showLogin('');
    

    to

    if (!ajaxSessionIsRegistered('customer_id')) $this->showCreateAccount('');
    

     

    function: PerformLogin

    change

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

    to

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

     

     

    change code

    $shipping_error = false;
    $shipping_buffer = $this->performAction2Buffer("showShipping", $get, $shipping_error);
    echo '<divresult name="shipping_area">'.$shipping_buffer.'</divresult>';
    

    to

    $payment_error = false;
    $payment_buffer = $this->performAction2Buffer("showPayment", $get, $payment_error);
    echo '<divresult name="payment_area">'.$payment_buffer.'</divresult>';
    

     

    function: _PerformLogin

    change

    $this->showPayment('');
    

    to

    $this->showShipping('');
    

     

    function: PerformCreateAccount

    change

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

    to

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

     

    change

    $payment_error = false;
    $payment_buffer = $this->performAction2Buffer("showPayment", $get, $payment_error);
    echo '<divresult name="payment_area">'.$payment_buffer.'</divresult>';
    

    to

    $shipping_error = false;
    $shipping_buffer = $this->performAction2Buffer("showShipping", $get, $shipping_error);
    echo '<divresult name="shipping_area">'.$shipping_buffer.'</divresult>';
    

     

    function: _PerformCreateAccount

    change

    $this->showShipping('');
    

    to

    $this->showPayment('');
    

     

    file: ajaxManager.js

    function: ajaxPerformLogin

    change

    ajaxSendRequest(url,data,true,'payment_area', true, "POST");
    

    to

    ajaxSendRequest(url,data,true,'shipping_area', true, "POST");
    

     

    change

    ajaxSendRequest('ajaxAction=PerformLogin&email_address='+login_email_address+'&password='+login_password,ajaxUpdateContentMulti,true,'payment_area', false);
    

    to

    ajaxSendRequest('ajaxAction=PerformLogin&email_address='+login_email_address+'&password='+login_password,ajaxUpdateContentMulti,true,'shipping_area', false);
    

     

    function: ajaxPerformCreateAccount

    change

    ajaxSendRequest(url,data,true,'shipping_area', true, "POST");
    

    ajaxSendRequest(url,data,true,'payment_area', true, "POST");
    

     

    and change

    , ajaxUpdateContentMulti, true, 'shipping_area', false);
    

    to

    , ajaxUpdateContentMulti, true, 'payment_area', false);
    

     

    and thats it. Hope I have not forgotten something :). Everything seems to be working fine afterwards.


  3. Hi

     

    how exactly is controlled order of boxes? I understand code for boxes is in relevant functions in ajaxManagerTest.class.php as showPaymentInfo, showChangeAddress and all other show... functions, but where exactly is code which defines what is order of these function calls? I was not able to find it :). Also if I would like to have login box in shipping_area and create account in "payment_area" how to do it? :). I tried to change this in several places and without luck

     

    thanks


  4. Hi

     

    By setting defaults I meant setting default payment and shipping. I coded dependency between shipping and payment (each shipping method has list of allowed payment methods - it is currently hard coded but it works :) ). So I had to find out the way to control default values to not break dependency rules. I was able to fix php code, but problem was javascript defaults stored in variables selected_shipping and selected_payment. These were always zero and only clicking on radio button set them correctly. So when I for example didn't click any radio button and just clicked "update" button, always shipping and payment with index 0 was taken. Thanks to hidden img hack I was able set correct values also in javascript :)

     

    My next problem now is this:

     

    I have created shopping cart box in header and need to update its quantity and total price. This I was able to do just with changing IDs and classes of some objects. However one thing is still open - in header I have information text which is stating something like this "Buy more for 23 EUR and get another 6% discount". Of course I have to update this text when total in cart changes. So now I'm looking for place to fix this :) My guess is jquery-oscart.js from where I got also those IDs and classes :)


  5. I was able to do defaults at last... I used hidden img tag with onload script which set all javascript variables correctly. Now I'm fighting with another problem. I built into this package dependency between shipping and payment modules. When shipping and payment modules are in edit mode, visibility is working fine (it means payment modules which should not be allowed for specific shipping module are now correctly disabled). However I need to fix "update" part - it means when shipping method is selected and also payment method is selected, I have to correct behavior after clicking on "update" buttons. It means when I click update on shipping module, also payment module has to go to edit mode because of possible dependency changes. And if clicking update on payment module, it has to show only dependant modules:

     

    1. regarding update of payment modules, I might be able to fix it - I have already idea how to do it.

    2. regarding update of shipping modules I have problem. I tried to change refreshshipping this way:

     

    function ajaxRefreshShipping(async) {

    ajaxSendRequest('ajaxAction=showShipping',ajaxUpdateContentMulti,true,'shipping_area', async);

    ajaxSendRequest('ajaxAction=showPayment',ajaxUpdateContentMulti,true,'payment_area', async);

    return false;

    }

     

    but it is not working. I was looking for solution but so far without luck:(. How can I enable for editing shipping and also payment areas?


  6. Dr.Rolex: I tried your code and based on that I fixed mine. I will do some tests. Thank you!.

     

    I have just few questions:

     

    1. I think this line is already obsolete in form_check.js.php, right? Object "selected" is nowhere used.

     

    if (selected) selected.className = 'moduleRow';

     

    2. I didn't change anything in ajaxManagerTest.class.php but I see your code is already using tables and not divs. So I have adapted form_check.js.php this way:

     

    $('body').on('click', '.moduleRow', function(event){
    $(this).parent().find('div').removeClass('moduleRowSelected');
    $(this).parent().find('input[type=radio]').attr('checked',false);
    $(this).addClass('moduleRowSelected');
    $(this).find('input[type=radio]').prop('checked',true);
    ....

     

    3. How exactly are you naming values of radio buttons?

     

    If you name one radio button shipping_0 and then you name another one payment_0, clicking on shipping_0 will affect also radio button in payment area (also payment_0 will be clicked, because of that "0" in name). This is because of form_check.js.php code. I thought about solution to have global $radio_buttons variable and just increase it through all radio buttons. At the end I change code in form_check.js.php. This is full click function:

     

     

    $('body').on('click', '.moduleRow', function(event){
    $(this).parent().find('div').removeClass('moduleRowSelected');
    $(this).parent().find('input[type=radio]').attr('checked',false);
    $(this).addClass('moduleRowSelected');
    $(this).find('input[type=radio]').prop('checked',true);
    
    buttonselect = $(this).attr('value');
    
    var selectable = $(this).find('input[type=radio]').prop('id');
    
    // one button is not an array
    var shipping = document.getElementById('shipping');
    if (shipping)
    {
    	 shipping.checked=true;
    }
    
    if (selectable.search("shipping_") == 0)
    {
    	 selected_shipping = buttonselect;
    }
    
    if (selectable.search("address_") == 0)
    {
    	 selected_address = buttonselect;
    }
    
    if (selectable.search("payment_") == 0)
    {
    	 selected_payment = buttonselect;
    }
    
    if (selectable.search("payment_address_") == 0)
    {
    	 selected_payment_address = buttonselect;
    }
    
    });
    

     

    thanks


  7. I used very long time header_tags_controller. Now I'm converting my site to 2.3.3.4 from old 2.2. I checked header tags addons and see this one is using new system introduced in 2.3 - header tags modules. It is very easy to install and not to many changes into existing files. Thats why I like it more than controller. However what I miss from controller is "fill tags" functionality. Thats why I started to think about creating default meta tags in case seo fields are empty. For products it is actually done - I just started to use osc_get_mini_description. Same approach I did for categories and manufacturers (just copy&paste existing osc_get_mini_description and osc_split_mini_description and change fields and tables). One think why I write is I had to change all coalesce sql calls. Currently it takes empty string as valid value. I changed it to this:

     

    (use nullif functions for all seo fields): this way empty values are converted to NULL

     

    here is one example from osc_get_mini_description fnc

     

    $product_query = tep_db_query("select coalesce(nullif(products_mini_description,''), nullif(products_seo_description,''), LEFT(products_description, 300)) as products_precis from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int)$products_id . "' and language_id = '" . (int)$languages_id . "'");


  8. I found another problem but I cannot find place to fix it :). Could you please help? Problem is with default selected shipping and payment methods. Even though default is selected correctly (it means DIV is created correctly with id="defaultSelected" class="moduleRowSelected" ) however when using "update" button (don't change radio selection, just click update), it uses variables from javascript: selected_payment and selected_shipping which are not set correctly and have default 0.

     

    These javascript values are set only after calling "selectRowEffect" funtion. I don't know how to call this function automatically after first start. I tried

     

    $(document).ready(function(){

     

    but it seems this function is called before AJAX requests. So it doesn't work. I think update should be somehow called through AJAX but I don't know how?


  9. Which way did you install both this Add-On (Fast Checkout) and jQuery Shopping cart?

     

    If you used code from the file I uploaded a couple of Post's ago, then the code is a bit outdated, I just made it to make it function and left you to do the rest. You should download the latest version of jQuery Shopping Cart and look for changes and try to reapply them so the animations flow flawlessly and Attributes work properly. Do you have problems just with the Drag & Drop or both that and adding a product with a Buy Now button?

     

    well actually I'm using code from Ajax Fast checkout 2.3.3 Rev2 from folder: catalog_for_jQuery_Shopping_Cart and I have just merged some changes from your last post of whole shop. I didn't know how to use drag and drop, but I saw your last post where changes into these files were done:

     

    bm_best_sellers.php

    bm_cycle_whats_new

    bm_order_history

    bm_reviews

    bm_specials

    bm_whats_new

    also_purchased_products

    new_products

    product_listing

     

    so basically in all files where products are shown were done changes to add class="draggable" and other attributes (rel, data-id, id). I was not aware how to use dragging (I never find guide for it, just found it in your sources). So after merging changes from your post I was able to use drag&drop from mentioned files. So drag and drop is now working fine.

     

    However in each of those file you had section about 30 lines long starting with " // Comment the code below if you don't use attributes". So it seems to be related for attributes and this is not working. I don't see anywhere attributes shown when doing dragging.


  10. yeah I thought about this also, maybe that would have been better option :). I installed quite a lot of addons in old system and did some customizations there therefore I decided to do it as I described. I was avoiding it many months but my server admin wants to do switch from PHP 5.3 to 5.4 so I was forced to do something with it :)

     

    Anyhow it took me maybe 1 week so it was not so bad. I used araxis merge tool - without it it would be much more painful. Thanks to araxis a lot of merges where done automatically. Afterwards I did once again compare with original 2.3.3.4 to understand differences

     

    The benefit now is I don't need to do many DB changes - just 2.3.3.4 relevant which I found on the web.

     

    After playing around with new 2.3.3.4 I like it became more modular. A lot of addons can be installed as modules. Knowing this before maybe I would have done it your way :)


  11. Hi

     

    let me explain it:

     

    original autocomplete.php starts with "require('includes/application_top.php')". Because of this autocomplete was not showing data (it was indeed executing query on background, but results of that query were not showed). I didn't change application_top.php. I just removed it from autocomplete.php and put there just some includes which you can see in my last post. This way everything worked.

     

    regarding mysqli in latest oscommerce 2.3.3.4 you can find this in database.php

     

       $$link = mysqli_connect($server, $username, $password, $database);
       if ( !mysqli_connect_errno() ) {
      mysqli_set_charset($$link, 'utf8');
       }
    

     

    and in same file from line 160 to the end you can see this:

     if ( !function_exists('mysqli_connect') ) {
    

     

    so this is fallback to old mysql code. So I was not changing anything from oscommerce source. I just changed autocomplete.php to not include application_top but rather few specific includes. This worked for me.

     

    I'm doing now upgrade from 2.2rc2a to 2.3.3.4 and this is huge step. A lot of work but at last I have my shop running at least from technical point of view. I like 960 grid system introduced in new oscommerce but have to drill down to understand how to move my old design to new oscommerce. I was using in old shop STS which is not working in new oscommerce so I have to deal somehow with 960grid. But actually I like it. I installed few addons to control layout and JQuery versions from admin and also templates, so changing layout and design is quite quick now. But still I have to do some changes or study how to do them with JQuery :)

     

    At the end new oscommerce with you AJAX addons is really great mix :) thank you


  12. This is the code of autocomplete which is working for me fine. So something what application_top was including caused the problem before.

     

    <?php
    // load server configuration parameters
    if (file_exists('includes/local/configure.php')) { // for developers
     include('includes/local/configure.php');
    } else {
     include('includes/configure.php');
    }
    // define our general functions used application-wide
    require(DIR_WS_FUNCTIONS . 'general.php');
    require(DIR_WS_FUNCTIONS . 'html_output.php');
    // include the list of project database tables
    require(DIR_WS_INCLUDES . 'database_tables.php');
    // include the database functions
    require(DIR_WS_FUNCTIONS . 'database.php');
    // include the list of project filenames
    require(DIR_WS_INCLUDES . 'filenames.php');
    
    tep_db_connect() or die('Unable to connect to database server!');
    
    $return_arr = array();
    
    $keyword = tep_db_prepare_input($_GET['term']);
    $fetch = tep_db_query("select pd.products_id, pd.products_name from " . TABLE_PRODUCTS_DESCRIPTION . " pd left join " . TABLE_PRODUCTS . " p on pd.products_id = p.products_id WHERE p.products_status = '1' and p.products_id = pd.products_id and pd.language_id = '1' and pd.products_name LIKE '%" . tep_db_input($keyword) . "%'  LIMIT 0,10");
    
    while ($row = tep_db_fetch_array($fetch))
    {
     $row_array['id'] = tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . (int)$row['products_id']);
     $row_array['value'] = $row['products_name'];
     array_push($return_arr, $row_array);
    }
    
    echo json_encode($return_arr);
    flush();
    ?>
    


  13. ok shopping card issue solved. I had to include also accounting.min.js. Without it updating of cart box is not working. This file is not included anywhere, I found it in zipped shop you sent. I was not able to make workable your shopping_cart.php. I had to bring back this code:

     

    if ( (int)$_GET['ajax'] )

    {

    echo '<span id="boxcart-total-new" style="display: none;">' . $currencies->format($cart->show_total()) . '</span>';

    }

     

    and remove this ID from file down bellow. So actually shopping cart from original ZIP is working fine at last so accounting file was missing:). btw. jquery-oscart.js from you zipped shop is showing error in jquery.min.js (I use 2.0.3 and tried also 2.0.2) so I had to roll back to file from original zip. Anyhow at last it is working.

     

    Now I'm going to analyze why autocomplete is not working


  14. I tried to compare code, merge changes but still getting no updates to shopping card box :(. I tried to use exactly same /shopping_cart.php and \includes\modules\boxes\bm_shopping_cart.php and no change. I think I will have to debug ajax to find root cause.

     

    btw. another question to "jQuery-UI Autocomplete". Any idea why list of search results generated by ajax is not shown in search box? I can see request is send and also result generated, but result is not shown anywhere


  15. I have this addon running with ajax shopping cart. I have two problems to fix:

     

    1. in shopping_cart.php is not updated shopping cart box Total, when I change count of some product. It is working fine in ajax_checkout.php.

    2. I have to set some dependencies between payment types and shipping types. Is it already configurable somewhere or do I have to code it?

     

    thanks

×