He creado un carrito de compra, donde todo los productos estan en un XML
Código
<?xml version="1.0" encoding="utf-8"?> <listings> <listing> <title>Art. 1.1 - Uso excesivo del claxon</title> <description>Utilizar de forma repetida el claxon</description> <price>250</price> <carcel>2</carcel> <images/> <url>0</url> </listing> <listing> <title>Art. 1.2 - Giro indebido</title> <description>Hacer un cambio de sentido pisando la linea continua o en zonas no habilitadas</description> <price>250</price> <carcel>2</carcel> <images/> <url>1</url> </listing> <listing> <title>Art 1.3 - Circular en sentido contrario</title> <description>Conductor que cons u vehiculo circula o invade el sentido contrario</description> <price>500</price> <carcel>2</carcel> <images/> <url>2</url> </listing> <listing> <title>Art 1.4 - Estacionar en zonas no habilitadas y obstruir la cinculacion</title> <description>Abandonar el vehiculo en medio de la calzada o en zonas en la cueles no proceda</description> <price>250</price> <carcel>2</carcel> <images/> <url>3</url> </listing> <listing> <title>Art 1.5 - Ignorar las señales de transito</title> <description>Hcaer caso omiso de las señales verticales</description> <price>250</price> <carcel>2</carcel> <images/> <url>4</url> </listing> <listing> <title>Art 1.6 - Saltarse un semaforo</title> <description>Saltarse o no realizar los 3 segundos de parada en un semaforo</description> <price>400</price> <carcel>2</carcel> <images/> <url>5</url> </listing> </listings>
Para ver los productos en el index he creado un PHP que visualice el xml
Código
<?php ?> <br/> <br/> <div id="resultswrapper"> <h2 class="pull-left no-margin"> <?php { echo $this->texts["search_results"]; } else { echo $this->texts["our_ads"]; } ?> </h2> <div class="clearfix"></div> <hr class="no-margin"/> <br/> <script src="js/results.js"></script> <div class="clearfix"></div> <div class="results-container"> <?php { $num=1; } else { $num=$_REQUEST["num"]; $this->ms_i($num); } $listing_counter = -1; $price_from = 0; $price_to = 0; $min_price = 0; $max_price = 0; $iTotResults = 0; { { $price_from=$amount_items[0]; $price_to=$amount_items[1]; } } $script_products=""; $script_products_carcel=""; $script_product_prices=""; foreach ($listings->listing as $listing) { $listing_counter++; //refine search { } { if ( && ) { continue; } } if($price_from!=0&&$price_to!=0) { if($current_price<$price_from) continue; if($current_price>$price_to) continue; } //end refine search if($current_price>$max_price) $max_price=$current_price; if($min_price==0) { $min_price=$current_price; } else if($min_price>$current_price) { $min_price=$current_price; } if($iTotResults>=($num-1)*$PageSize&&$iTotResults<$num*$PageSize) { if($this->settings["website"]["seo_urls"]==1) { $strLink = "product-".$this->format_str(strip_tags(stripslashes($listing->title)))."-".$listing_counter.".html"; } else { $strLink = "index.php?page=details&id=".$listing_counter; } ?> <div class="panel panel-default search-result"> <div class="panel-heading"> <h3 class="panel-title"> <a href="<?php echo $strLink;?>" class="search-result-title"><?php echo $listing->title;?></a> </h3> </div> <div class="panel-body"> <div class="row"> <div class="col-sm-8 col-xs-12"> <div class="details"> <p class="description"> </p> <?php { ?> <span class="listing-price"><?php echo $this->texts["price"];?>: <strong><?php echo $this->settings["website"]["currency"].number_format(floatval($listing->price), 0);?></strong></span> <?php } ?> <?php { ?> <span class="listing-price"><?php echo $this->texts["carcel"];?>: <strong><?php echo $this->settings[""]["currency"].number_format(floatval($listing->carcel), 0);?> meses</strong></span> <?php } ?> <span class="is_r_featured"></span> </div> </div> </div> <div class="row"> <div class="col-xs-6"> </div> <div class="col-xs-6"> <div class="text-right"> <a class="btn btn-md btn-info" href="javascript:AddToCart(<?php echo $listing_counter;?>)"><?php echo $this->texts["add_to_cart"];?></a> </div> </div> </div> </div> </div> <?php } $iTotResults++; } ?> </div> <div class="clearfix"></div> </div> <script> var currency_symbol="<?php echo $this->settings["website"]["currency"];?>"; var currency_code="<?php echo $this->settings["website"]["currency_code"];?>"; var pp_address="<?php echo $this->SimpleEncrypt("123", $this->settings["website"]["admin_email"]);?>"; var products=Array(); <?php echo $script_products;?> var product_prices=Array(); <?php echo $script_product_prices;?> </script> <script> var min_price=<?php echo $min_price;?>; var max_price=<?php echo $max_price;?>; </script> <?php $this->Title($this->texts["our_ads"]); $this->MetaDescription(""); ?> <div id="loadmoreajaxloader" style="display:none;"><center><img src="images/loading.gif" /></center></div> <script type="text/javascript"> var page_num=2; $(window).scroll(function() { if($(window).scrollTop() == $(document).height() - $(window).height()) { $('div#loadmoreajaxloader').show(); $.ajax({ url: "load_products.php?num="+page_num+"&view="+current_view, success: function(html) { if(html) { $("#resultswrapper").append(html); $('div#loadmoreajaxloader').hide(); page_num++; }else { $('div#loadmoreajaxloader').html(''); } } }); } }); $(document).ready(function() { InitCart(); }); </script>
No se mucho de PHP, mi preguntas es, se puede agregar algo en el XML como <categoria>1</categoria>
<categoria>2</categoria>
y que en el PHP poner que si la categoria es 1 que muestre ese producto y si es 2 que muestre solo los producto 2?