cart/index.php

Vista por defecto del carrito - Página de checkout

Carrito

Es el template del carrito en 1 paso. Puedes dividir el proceso en los pasos que quieras

Objetos disponibles

Descripción

$_cart

Carrito.

$_country

Países

$_carrier

Formas de envío.

$_totalCarriers

Cantidad de formas de envío.

$_stores

Tiendas.

$_totalStores

Cantidad de tiendas.

$_paymentMethod

Formas de pago.

$_totalPaymentMethods

Cantidad de formas de pago.

$_maxPrice

Precio máximo en la categoría.

$_docType

Tipos de documento.

$_addressComplete

Dirección de usuario cargada (bool).

$_billingAddressComplete

Dirección de facturación de usuario cargada (bool).

$_userCredits

Créditos de usuario.

$_promoTexts

Textos de promociones activas (array).

Por defecto el carrito se muestra en 1 sólo paso y en modo compra sin registro y sin login previo.

Puedes configurar el proceso de checkout en la cantidad de pasos o flujo según prefieras.También crear restricciones según el usuario esté registrado o no y logueado o no previamente.

Código de ejemplo de un carrito completo en 1 paso

Resumen de compra + Ingreso de datos personales y envío + selección de forma de pago y envío

<h1><?=($_totalPaymentMethods ? 'Carrito' : 'Lista de productos a consultar')?></h1>

<?php if(count($_cart->quantity()) == 0): ?>
<p>Tu carrito de compras está vacío.</p>	
<?php else: ?>
<form action="<?=HOST?>carrito" method="post" id="cartContent">
	<table class="cart">
		<tr>
			<th></th>
			<th></th>
			<th>Producto</th>
			<th class="price quantity">Cantidad</th>
			<th class="price">Precio por unidad</th>
			<th class="price">Total</th>
		</tr>
		<?php 
			foreach($_cart->products() as $i => $data):
				$image = $_front->thumb($data['product']->image()->get('image'), 150, 150);
					
		?>
		<tr>
			<td class="delete">
				<a href="<?=HOST?>carrito/eliminar/<?=$i?>"><i class="fa fa-times"></i></a>
			</td>
			<td class="img">
				<img src="<?=$image?>" alt="<?=$data['product']->get('name')?>" width="40" height="40" /></td>
			<td>
				<img src="<?=$image?>" alt="<?=$data['product']->get('name')?>" width="40" height="40" class="mobile" />
				
				<?=$data['product']->get('name')?>
				
				<?php if($data['versionId']): ?>
				<p class="version"><?=$data['version']->info()?></p>
				<?php endif; ?>
				
				<?php if($data['product']->get('manufacturerId')): ?>
				<p class="manufacturer"><?=$data['product']->get('manufacturers.name')?></p>
				<?php endif; ?>
				
				<?php if($data['startDate'] != '' && $data['endDate'] != ''): ?>
				<p class="date">Desde el <?=$_front->date($data['startDate'])?> hasta el <?=$_front->date($data['endDate'])?></p>
				<?php endif; ?>
				
				<div class="mobile">
					<input type="text" name="quantities[<?=$i?>]" value="<?=$data['quantity']?>" size="2" />
					<button type="submit" class="button btn btn-primary" name="update" value="1">Actualizar</button>
				</div>
			</td>
			<td class="price quantity">
				
				<?php if($data['startDate'] != '' && $data['endDate'] != ''): ?>
					<?=$data['quantity']?>
					noche<?=($data['quantity'] != 1 ? 's' : '')?>
				<?php else: ?>
					<input type="text" name="quantities[<?=$i?>]" value="<?=$data['quantity']?>" size="2" />
					<button type="submit" class="button btn btn-primary" name="update" value="1">Actualizar</button>
				<?php endif; ?>
				
			</td>
			<td class="price">
				<?php if($data['product']->discount()): ?>
				<s><?=$_front->price($data['product']->originalPrice())?></s>
				<?php endif; ?>
				
				<?php if($data['price']): ?>
				<?=$_front->price($data['price'])?>
				<?php else: ?>
				Gratis
				<?php endif; ?>
			</td>
			<td class="price">
				<?php if($data['total']): ?>
				<?=$_front->price($data['total'])?>
				<?php else: ?>
				Gratis
				<?php endif; ?>
			</td>
		</tr>		
		<?php endforeach; ?>
		<?php if($_cart->hasDiscounts()):
				foreach($_cart->discounts() as $index => $discount): ?>
		<tr>
			<td class="delete"><a href="<?=HOST?>carrito/eliminarDescuento/<?=$index?>"><i class="fa fa-times"></i></a></td>
			<td class="img"></td>
			<td><?=$discount->get('description')?></td>
			<td class="price"></td>
			<td class="price"><?=$discount->description()?></td>
			<td class="price">-<?=$_front->price($discount->amount($_cart))?></td>
		</tr>
		<?php endforeach; endif; ?>
		<tfoot>
			<?php if($_cart->creditsAmount()): ?>
			<tr class="even">
				<td></td>
				<td></td>
				<td></td>
				<td></td>
				<td class="name"><?=Configuration::value('CREDITS_NAME')?></td>
		        <td class="price"><?=$_front->price(-$_cart->creditsAmount())?></td>
		    </tr>
		    <?php endif; ?>
			<?php if($_totalCarriers): ?>
			<tr class="even">
				<td></td>
				<td></td>
				<td></td>
				<td></td>
				<td class="name">Costo de envío</td>
		        <td id="shipping" class="price">Ingresa tu dirección</td>
		    </tr>
		    <?php endif; ?>
			<tr>
				<td></td>
				<td></td>
				<td></td>
				<td></td>
				<td class="name">Total con impuestos</td>
				<td class="price" id="total"><?=$_front->price($_cart->total())?></td>
			</tr>
		</tfoot>
	</table>
</form>

<div class="clearfix">
	
	<?php if(Configuration::value('DISCOUNTS') == 1 && (!$_cart->hasDiscounts() || Configuration::value('MULTIPLE_DISCOUNTS'))): ?>
	<form action="<?=HOST?>carrito" method="post">
		<fieldset id="discount">
			
			<h2>Tengo un cupón de descuento</h2>
			
			<label for="disc">
				Código
				<input type="text" name="discount" id="disc" value="<?=post('discount')?>" />
			</label>
			
			<input type="submit" value="Agregar" class="button btn btn-primary" />
			
		</fieldset>
	</form>
	<?php endif; ?>
	
	<?php if(Configuration::value('CREDITS') == 1 && $_auth->isLogged() && $_auth->user()->credits() > 0): ?>
	<form action="<?=HOST?>carrito" method="post">
		<fieldset id="credits">
			
			<h2>Quiero usar mis <?=Configuration::value('CREDITS_NAME', 'puntos')?></h2>
			
			<label for="creds">
				<?=ucfirst(Configuration::value('CREDITS_NAME', 'puntos'))?>
				<input type="text" name="credits" id="creds" placeholder="<?=Configuration::value('CREDITS_NAME', 'puntos')?> a utilizar" value="<?=($_cart->credits() > 0 ? $_cart->credits() : '')?>" data-min="0" data-max="<?=$_maxCredits?>" class="numeric stepper" />
			</label>
			
			<input type="submit" value="Agregar" class="button btn btn-primary" />
			
			<p>Tienes <?=$_maxCredits?> <?=Configuration::value('CREDITS_NAME', 'puntos')?></p>
		</fieldset>
	</form>
	<?php endif; ?>
	
</div>

<form action="<?=HOST?>carrito" method="post" id="pay">
<?php if(Configuration::value('NO_LOGIN') == 1 || $_auth->isLogged()): ?>

	<div class="clearfix">
		
		<div class="address">
		
			<h2>Completa tus datos</h2>
			
			<div class="clearfix">
				
				<label for="name" class="two">
					Nombre
					<input type="text" name="name" id="name" value="<?=post('name')?>" required="required" />
				</label>
			
				<label for="surname" class="two">
					Apellido
					<input type="text" name="surname" id="surname" value="<?=post('surname')?>" required="required" />
				</label>
		
			</div>
			
			<div class="clearfix">
			
				<label for="email" class="two">
					E-Mail
					<input type="email" name="email" id="email" value="<?=post('email')?>" required="required" />
				</label>
				
				<?php if(Configuration::value('DISPLAY_TEL')): ?>
				<label for="tel" class="two">
					Teléfono
					<input type="text" name="tel" id="tel" value="<?=post('tel')?>" <?=(Configuration::value('REQUIRE_TEL') ? 'required="required"' : '')?> />
				</label>
				<?php endif; ?>

			</div>

			<div class="clearfix">
				
				<?php if(Configuration::value('DISPLAY_MOBILE')): ?>
				<label for="mobile" class="two">
					Móvil
					<input type="text" name="mobile" id="mobile" value="<?=post('mobile')?>" <?=(Configuration::value('REQUIRE_MOBILE') ? 'required="required"' : '')?> />
				</label>
				<?php endif; ?>
				
				<?php if(Configuration::value('DISPLAY_DOC')): ?>
				<label for="doc" class="two">
					Documento
					<input type="text" name="doc" id="doc" value="<?=post('doc')?>" <?=(Configuration::value('REQUIRE_DOC') ? 'required="required"' : '')?> />
				</label>
				<?php endif; ?>
			</div>
		
			<div class="clearfix">
				
				<?php if(Configuration::value('DISPLAY_COUNTRY')): ?>
				<label for="countryId">
					País
					<select name="countryId" id="countryId" <?=(Configuration::value('REQUIRE_COUNTRY') ? 'required="required"' : '')?>>
					<?php
						while($_country->getNext())
							echo '<option value="'.$_country->get('id').'" '.(post('countryId') == $_country->get('id') ? 'selected' : '').'>'.$_country->get('name').'</option>';
					?>
					</select>
				</label>
				<?php else: $_country->getNext(); ?>
				<select id="countryId" name="countryId" style="display:none"><option value="<?=$_country->get('id')?>" selected="selected"></option></select>
				<?php endif; ?>

			</div>
			
			<div class="clearfix">
							
				<label for="stateId" class="two">
					<?=($_shop->get('shopCountryId') == 2 ? 'Departamento' : 'Provincia')?>
					<select name="stateId" id="stateId" data-selected="<?=post('stateId')?>" <?=(Configuration::value('REQUIRE_STATE') ? 'required="required"' : '')?>></select>
				</label>
				
				<?php if(Configuration::value('DISPLAY_CITY')): ?>
				<label for="city" class="two">
					Ciudad
					<select id="cityId" name="cityId" style="display:none"></select>
					<input type="text" name="city" id="city" value="<?=post('city')?>" />
				</label>
				<?php endif; ?>

			</div>
			
			<div class="clearfix">
						
				<label for="address">
					Dirección
					<input type="text" name="address" id="address" value="<?=post('address')?>" required="required" />
				</label>
				
			</div>
			
			<?php if(Configuration::value('DISPLAY_CP')): ?>
			<div class="clearfix">
				
				<label for="cp" class="two">
					Código postal
					<input type="text" name="cp" id="cp" value="<?=post('cp')?>" <?=(Configuration::value('REQUIRE_CP') ? 'required="required"' : '')?> />
				</label>
				
			</div>
			<?php endif; ?>
			
			<?php if(Configuration::value('BILLING_ADDRESS')): ?>
			<h2>Dirección de facturación</h2>
			
			<label class="checkbox">
				<input type="checkbox" name="saveBillingAddress" id="saveBillingAddress" value="1" />
				Quiero ingresar una dirección de facturación distinta a la de envío
			</label>
			
			<div id="billingAddress">
				
				<div class="clearfix">
					
					<label for="billingName" class="two">
						Nombre
						<input type="text" name="billingName" id="billingName" value="<?=post('billingName')?>" />
					</label>
					
					<label for="billingSurname" class="two">
						Apellido
						<input type="text" name="billingSurname" id="billingSurname" value="<?=post('billingSurname')?>" />
					</label>
	
				</div>
	
				<div class="clearfix">
					
					<label for="billingCountryId" class="two">
						País
						<select name="billingCountryId" id="billingCountryId">
						<?php
							$_country->reset();
							while($_country->getNext())
								echo '<option value="'.$_country->get('id').'" '.(post('billingCountryId') == $_country->get('id') ? 'selected' : '').'>'.$_country->get('name').'</option>';
						?>
						</select>
					</label>
					
					<?php if(Configuration::value('DISPLAY_CP')): ?>
					<label for="billingCp" class="two">
						Código postal
						<input type="text" name="billingCp" id="billingCp" value="<?=post('billingCp')?>" />
					</label>
					<?php endif; ?>
	
				</div>
				
				<div class="clearfix">
								
					<label for="billingStateId" class="two">
						<?=($_shop->get('shopCountryId') == 2 ? 'Departamento' : 'Provincia')?>
						<select name="billingStateId" id="billingStateId" data-selected="<?=post('billingStateId')?>"></select>
					</label>
					
					<label for="billingCity" class="two">
						Ciudad
						<select id="billingCityId" name="billingCityId" style="display:none"></select>
						<input type="text" name="billingCity" id="billingCity" value="<?=post('billingCity')?>" />
					</label>
	
				</div>
				
				<div class="clearfix">
							
					<label for="billingAddress" class="two">
						Dirección
						<input type="text" name="billingAddress" id="billingAddress" value="<?=post('billingAddress')?>" />
					</label>
					
					<?php if(Configuration::value('DISPLAY_TEL')): ?>
					<label for="billingTel" class="two">
						Teléfono
						<input type="text" name="billingTel" id="billingTel" value="<?=post('billingTel')?>" />
					</label>
					<?php endif; ?>
					
				</div>
				
			</div>
			<?php endif; ?>			
			
			<?php if(Configuration::value('DISPLAY_COMMENTS')): ?>
			<div class="clearfix">
											
				<label class="full">
					¿Tienes algún comentario?
					<textarea rows="5" cols="20" name="comments" id="comments"><?=post('comments')?></textarea>
				</label>
	
			</div>
			<?php endif; ?>
			
		</div>
		
		<?php if($_totalCarriers || $_totalPaymentMethods): ?>
		<div class="options">
			
			<?php if($_totalCarriers): ?>
			<div class="carriers">
			
				<h2>Forma de envío:</h2>
				
				<?php while($_carrier->getNext()): ?>
				<label class="carrier" data-id="<?=$_carrier->get('id')?>">
					<input type="radio" name="carrierId" value="<?=$_carrier->get('id')?>" data-name="<?=$_carrier->get('name')?>" />
					<?=$_carrier->get('name')?>
					
					<?php if(($delivery = $_carrier->get('delivery'))): ?>
					<small>Envío en <span class="delivery"><?=$delivery?> día<?=($delivery != 1 ? 's' : '')?></span></small>
					<?php endif; ?>
				</label>			
				<?php endwhile; ?>
			
			</div>
			<?php endif; ?>
			
			<?php if($_totalPaymentMethods): ?>
			<div class="payment">
			
				<h2>Forma de pago:</h2>
				
				<?php while($_paymentMethod->getNext()): ?>
				<div class="paymentMethod">
					
					<label>
						<input type="radio" name="paymentMethodId" value="<?=$_paymentMethod->get('id')?>" data-name="<?=$_paymentMethod->get('name')?>" required="required" />
						
						<?php if(file_exists(__DIR__.'/../../images/carrito/pago'.$_paymentMethod->get('className').'.svg')): ?>
						<img src="<?=$_front->assetHost()?>themes/global/images/carrito/pago<?=$_paymentMethod->get('className')?>.svg" alt="<?=$_paymentMethod->get('name')?>" />
						<?php elseif(file_exists(__DIR__.'/../../images/carrito/pago'.$_paymentMethod->get('className').'.jpg')): ?>
						<img src="<?=$_front->assetHost()?>themes/global/images/carrito/pago<?=$_paymentMethod->get('className')?>.jpg" alt="<?=$_paymentMethod->get('name')?>" />
						<?php elseif(file_exists(__DIR__.'/../../images/carrito/pago'.$_paymentMethod->get('className').'.png')): ?>
						<img src="<?=$_front->assetHost()?>themes/global/images/carrito/pago<?=$_paymentMethod->get('className')?>.png" alt="<?=$_paymentMethod->get('name')?>" />
						<?php endif; ?>
						
						<span><?=($_paymentMethod->get('displayName') != '' ? $_paymentMethod->get('displayName') : $_paymentMethod->get('name'))?></span>
					</label>
					
					<?php if($_paymentMethod->service()->hasForm()): ?>
					<div class="paymentMethodForm paymentMethod<?=$_paymentMethod->get('id')?> paymentMethod<?=$_paymentMethod->get('className')?> clearfix">
						
						<fieldset>
							<?php 
								$fieldN = 0;
								foreach($_paymentMethod->service()->form() as $name => $field):
									$fieldN++;
							?>
							<label class="field<?=$fieldN?>">
								<?=$field['label']?>
								<?php if(isset($field['options'])): ?>
								<select name="<?=$name?>" required="required">
									<?php foreach($field['options'] as $value => $label): ?>
									<option value="<?=$value?>"><?=$label?></option>
									<?php endforeach; ?>
								</select>
								<?php else: ?>
								<input type="<?=(isset($field['type']) ? $field['type'] : 'text')?>" name="<?=$name?>" required="required" value="<?=(isset($field['value']) ? $field['value'] : '')?>" />
								<?php endif; ?>
							</label>
							<?php endforeach; ?>	
						</fieldset>
						
						<?php if($_paymentMethod->get('className') == 'PayUTarjeta'): ?>
						<div id="card"></div>
						<?php endif; ?>
						
					</div>
					<?php endif;?>
					
				</div>
				<?php endwhile; ?>
							
			</div>
			<?php endif; ?>
			
		</div>
		<?php endif; ?>
	
	</div>
	
	<div class="buttons">
		
		<a href="<?=HOST?>" class="button btn btn-secondary"><?=($_totalPaymentMethods ? 'Seguir comprando' : 'Seguir consultando')?></a>
		
		<div class="submit">
			<button type="submit" name="pagar" class="button btn btn-primary"><?=($_totalPaymentMethods ? 'Finalizar compra' : 'Enviar consulta')?></button>
		</div>
		
	</div>
	
<?php else: ?>
	
	<div class="buttons">
		
		<a href="<?=HOST?>" class="button btn btn-secondary"><?=($_totalPaymentMethods ? 'Seguir comprando' : 'Seguir consultando')?></a>
		
		<div class="submit">
			<a href="login?back=carrito" class="button btn btn-primary"><?=($_totalPaymentMethods ? 'Completar pedido' : 'Completar consulta')?></a>
		</div>
		
	</div>

<?php endif; ?>

<?php endif; ?>

</form>

Last updated

Was this helpful?