Adresa de facturare identica cu cea de livrare

Discutii despre script-uri si coduri PHP-MySQL, precum si lucru cu XML in PHP.
dim
Mesaje: 43

Adresa de facturare identica cu cea de livrare

Salut

Am o singura baza de date cu adrese
si am o pagina adresa_facturare.php in care afisez adresele disponibile din care pot sa selectez adresa si datele de facturare

Cod: Selectaţi tot

<form class="form-horizontal">
{% if addresses %}   
 <div id="payment-existing">
    
   <section class="section">
   
	 {% for address in addresses %}
     {% if address['address_id'] == address_id %}
	  <div class="adress_sel">
	
	 <input class="adress" type="radio" id="{{address.address_id }} 1" name="address_id" value="{{ address.address_id }}"checked="checked"/>
	 <label class="adress_lable" for="{{address.address_id }} 1"> 
	 <b>{{ address.firstname }} - <i>{{ address.lastname }}</i></b>
	 <br> {{ address.address_1 }}, {{ address.city }}, {{ address.zone }}, {{ address.country }}
	 </label>
	 </div>
	 {% else %}
	  <div class="adress_sel">
	 <input class="adress" type="radio" id="{{address.address_id }} 1"  name="address_id" value="{{ address.address_id }}"/>
	 <label class="adress_lable"   for="{{address.address_id }} 1">
	 <b>{{ address.firstname }} - <i> {{ address.lastname }}</i></b>
	 <br>{{ address.address_1 }}, {{ address.city }}, {{ address.zone }}, {{ address.country }}
	 </label>
	 </div>
	 {% endif %}
     {% endfor %}
	
   </section>
   
    <br>
   
    {% if shipping_required %}   
	<div class="checkbox">
         <label>
             <input type="checkbox" id="shipping_address" name="shipping_address" value="1" checked="checked" />
             {{ entry_shipping }}
	    </label>
    </div> 
    {% endif %}

     <br>
  	 
    <div>
    <label class="btn btn-primary pull-left ">
	  <i class="fa fa-plus  shopping-cart"></i><i class="shopping-cart_prefix"></i>
      <input class="add_adress" type="radio" name="payment_address" value="new" />
      {{ text_address_new }}</label>
   </div>
   
 
    <div id="adresa_livrare" class="livrare">
         <div class="buttons clearfix">
          <div class="pull-right">
           <input type="button" value="{{  text_checkout_shipping_address  }}" id="button-payment-address" data-loading-text="{{ text_loading }}" class="btn btn-primary" />
          </div>
        </div>
     </div>
	
	 <div id="adresa_livrare" class="continua">
         <div class="buttons clearfix">
          <div class="pull-right">
           <input type="button" value="{{ button_continue }}" id="button-payment-address" data-loading-text="{{ text_loading }}" class="btn btn-primary" />
          </div>
        </div>
    </div>
	
  </div>
 
  
 
 
  {% endif %}
</form>



<script type="text/javascript"><!--

   $(function () {
        $("#adresa_livrare").hide();
        $("#shipping_address").click(function () {
            if ($(this).is(":checked")) {		     
                $(".livrare").hide();
				$(".continua").show();				
            } else {
			    $(".livrare").show();
                $(".continua").hide();
               
            }
        });
    });

//--></script>




si o alta pagina adresa_livrare.php in care afisez aceleasi adresele din care pot sa selectez adresa de livrare

Cod: Selectaţi tot

<form class="form-horizontal">
  {% if addresses %}
  
   <div id="shipping-existing">
    
   <section class="section">
   
	 {% for address in addresses %}
     {% if address['address_id'] == address_id %}
	  <div class="adress_sel">
	
	 <input class="adress" type="radio" id="{{ address.address_id }}" name="address_id" value="{{ address.address_id }}"checked="checked"/>
	 <label class="adress_lable" for="{{ address.address_id }}"> 
	 <b>{{ address.firstname }} - <i>{{ address.lastname }}</i></b>
	 <br> {{ address.address_1 }}, {{ address.city }}, {{ address.zone }}, {{ address.country }}
	 </label>
	 </div>
	 {% else %}
	  <div class="adress_sel">
	 <input class="adress" type="radio" id="{{ address.address_id  }}"  name="address_id" value="{{ address.address_id }}"/>
	 <label class="adress_lable"   for="{{ address.address_id  }}">
	 <b>{{ address.firstname }} - <i> {{ address.lastname }}</i></b>
	 <br>{{ address.address_1 }}, {{ address.city }}, {{ address.zone }}, {{ address.country }}
	 </label>
	 </div>
	 {% endif %}
     {% endfor %}
	
   </section>
  
     
  
  	 
    <div>
    <label class="btn btn-primary pull-left ">
	  <i class="fa fa-plus  shopping-cart"></i><i class="shopping-cart_prefix"></i>
      <input class="add_adress" type="radio" name="shipping_address" value="new" />
      {{ text_address_new }}</label>
    </div>
	
	<div class="buttons clearfix">
          <div class="pull-right">
           <input type="button" value="{{ button_continue }}" id="button-shipping-address" data-loading-text="{{ text_loading }}" class="btn btn-primary" />
          </div>
        </div> 
 </div> 
 {% endif %}
</form> 
functioneza ok dar trebuie sa selectez manual ambele adrese
as dori daca poti sa ma ajut ca atunci cand e bifata optiunea aceiasi adresa din pagina adresa_facturare

Cod: Selectaţi tot

 
	<div class="checkbox">
         <label>
             <input type="checkbox" id="shipping_address" name="shipping_address" value="1" checked="checked" />
             {{ entry_shipping }}
	    </label>
    </div> 
  
formularul din pagina Adresa_livrare sa fie completat cu aceiasi valoare ca in adresa_facturare si sa treaca la pagina urmatoare cu metode de livrare

dim
Am incercat cu codu asta

Cod: Selectaţi tot

// Payment Address
$(document).delegate('#button-payment-address', 'click', function() {

               {% if shipping_required %}
                var shipping_address = $('#collapse-payment-address input[name=\'shipping_address\']:checked').prop('value'); 
				 

                    if (shipping_address) {
					    
						 $.ajax({
                         url: 'index.php?route=checkout/shipping_method',
                    dataType: 'html',
                    complete: function() {
                        $('#button-shipping-address').button('reset');
                    },
                        success: function(html) {
						
						     $.ajax({
                                url: 'index.php?route=checkout/shipping_address',
                                dataType: 'html',
                                success: function(html) {
								    $('#collapse-shipping-address .panel-body').html(html);
								
									$('#collapse-shipping-address').parent().find('.panel-heading .panel-title').html('<a href="#collapse-shipping-address" data-toggle="collapse" data-parent="#accordion" class="accordion-toggle">{{ text_checkout_shipping_address }} <i class="fa fa-caret-down"></i></a>');
                                },
                                error: function(xhr, ajaxOptions, thrownError) {
                                    alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
                                }
								
								
                            });	 
					        $('#collapse-shipping-method .panel-body').html(html);

							$('#collapse-shipping-method').parent().find('.panel-heading .panel-title').html('<a href="#collapse-shipping-method" data-toggle="collapse" data-parent="#accordion" class="accordion-toggle">{{ text_checkout_shipping_method }} <i class="fa fa-caret-down"></i></a>');
   							$('a[href=\'#collapse-shipping-method\']').trigger('click');

							$('#collapse-shipping-method').parent().find('.panel-heading .panel-title').html('{{ text_checkout_shipping_method }}');
							$('#collapse-payment-method').parent().find('.panel-heading .panel-title').html('{{ text_checkout_payment_method }}');
							$('#collapse-checkout-confirm').parent().find('.panel-heading .panel-title').html('{{ text_checkout_confirm }}');
                        },
                        error: function(xhr, ajaxOptions, thrownError) {
                            alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
                        }
                    });
				    } else {
                     $.ajax({
                        url: 'index.php?route=checkout/shipping_address',
                        dataType: 'html',
                        success: function(html) {
                             $('#collapse-shipping-address .panel-body').html(html);

							$('#collapse-shipping-address').parent().find('.panel-heading .panel-title').html('<a href="#collapse-shipping-address" data-toggle="collapse" data-parent="#accordion" class="accordion-toggle">{{ text_checkout_shipping_address }} <i class="fa fa-caret-down"></i></a>');

							$('a[href=\'#collapse-shipping-address\']').trigger('click');

							$('#collapse-shipping-method').parent().find('.panel-heading .panel-title').html('{{ text_checkout_shipping_method }}');
							$('#collapse-payment-method').parent().find('.panel-heading .panel-title').html('{{ text_checkout_payment_method }}');
							$('#collapse-checkout-confirm').parent().find('.panel-heading .panel-title').html('{{ text_checkout_confirm }}');
                        },
                        error: function(xhr, ajaxOptions, thrownError) {
                            alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
                        }
                    });
                }
                {% else %}
	               $.ajax({
                    url: 'index.php?route=checkout/payment_method',
                    dataType: 'html',
                    success: function(html) {
                        $('#collapse-payment-method .panel-body').html(html);
                        
						$('#collapse-payment-method').parent().find('.panel-heading .panel-title').html('<a href="#collapse-payment-method" data-toggle="collapse" data-parent="#accordion" class="accordion-toggle">{{ text_checkout_payment_method }} <i class="fa fa-caret-down"></i></a>');

						$('a[href=\'#collapse-payment-method\']').trigger('click');

						$('#collapse-checkout-confirm').parent().find('.panel-heading .panel-title').html('{{ text_checkout_confirm }}');
                    },
                    error: function(xhr, ajaxOptions, thrownError) {
                        alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
                    }
                }).done(function() {
					$.ajax({
						url: 'index.php?route=checkout/payment_address',
						dataType: 'html',
						success: function(html) {
							$('#collapse-payment-address .panel-body').html(html);
						},
						error: function(xhr, ajaxOptions, thrownError) {
							alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
						}
					     });				
				     });
                {% endif %}	
						
});

in felul acesta cand e bifat optiune imi sare peste pagina de adresa de livrare dar nu imi selecteza nici o adresa in cazul in care sunt la prima incercare iar daca trec eu si prin adresa de livrare o data o selecteaza tot timpu pe ultima setata de mine


ma poti ajuta te rog cu un sfat ?

giulian9
Salut, ai incercat sa treci variabila intr-o sesiune?
ex:

Cod: Selectaţi tot

$_SESSION['adresa'] = $variabila;

atunci cand adresele sunt identice , iar pe cealalta pagina folosesti un

Cod: Selectaţi tot

if (isset($_SESSION['adresa'])) ...
iar in cazul in care exista sesiunea inseamna ca a fost bifat si iei valorile de care ai nevoie.

Subiecte similare