Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/wreyesus/Sencillo_Carrito_de_Compras_en_PHP/llms.txt

Use this file to discover all available pages before exploring further.

The YUME|TEC checkout is a two-page flow. First, resumenc_compra.php presents a read-only summary of the cart alongside a short form where the customer confirms their display name and supplies an email address. When they submit that form, final.php takes over: it builds and sends an HTML order-confirmation email via PHPMailer, then constructs a PayPal _xclick payment form and auto-submits it with JavaScript so the customer lands on the PayPal payment page without having to click anything.

Order summary page (resumenc_compra.php)

resumenc_compra.php enforces authentication before showing any order data. If $_SESSION['usuario'] is not set, the visitor is immediately redirected to the registration/login page:
if (!isset($_SESSION["usuario"])) {
    header("location:nuevo_usuario.php?nologin=false");
}
Once the session check passes, the page loads $_SESSION['carrito'] into $compras and renders every non-NULL entry in a read-only table — customers cannot alter quantities on this page. Above the product list, two form fields collect the information needed to send the confirmation email:
  • Nombre — pre-filled with $_SESSION['usuario'] (the logged-in nickname), but editable.
  • E-Mail — an empty required field the customer must complete.
The entire summary table is wrapped in a single <form> that posts both fields to final.php. The cart itself does not need to be re-transmitted because final.php reads the same session.

final.php

final.php performs three actions in sequence when the order summary form is submitted:
1

Build the order email body

The script iterates over $_SESSION['carrito'], skipping NULL entries, and assembles an HTML email string listing each product with its unit price, quantity, and line total. The grand total is appended at the end.
2

Send confirmation emails via PHPMailer

A PHPMailer instance is configured with the store’s outgoing mail host and sender address. The email is addressed to the customer (using the address they entered on the summary page) and CC’d to the store’s internal inbox at [email protected].
3

Auto-submit the PayPal payment form

An HTML form targeting https://www.paypal.com/cgi-bin/webscr is written to the page. A small inline <script> block calls someter() immediately, which submits the form without any user interaction, redirecting the browser to PayPal’s hosted payment page.
The PayPal form that is rendered and auto-submitted looks like this:
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" name="pago" id="pago">
  <input type="hidden" name="cmd"           value="_xclick">
  <input type="hidden" name="business"      value="[email protected]">
  <input type="hidden" name="item_name"     value="YUME-TEC">
  <input type="hidden" name="item_number"   value="FM">
  <input type="hidden" name="amount"        value="<?php echo $total; ?>">
  <input type="hidden" name="no_shipping"   value="0">
  <input type="hidden" name="no_note"       value="1">
  <input type="hidden" name="currency_code" value="USD">
  <input type="hidden" name="lc"            value="ES">
  <input type="hidden" name="bn"            value="PP-BuyNowBF">
</form>
<script>
function someter() { document.pago.submit(); }
someter();
</script>
The total passed to PayPal is calculated in PHP directly from the session cart. There is no server-side validation or tamper-proofing on this value. Always cross-check received payment amounts against your expected order totals inside your PayPal merchant dashboard before fulfilling any order.

Order email format

final.php constructs the email body by looping over the cart array and building one line per product:
$pedido .= $compras[$i]['nombre'] . " ***** " . $compras[$i]['precio']
         . " x " . $compras[$i]['cantidad']
         . " Total: " . ($compras[$i]['precio'] * $compras[$i]['cantidad']) . " Dolares <br>";
After the product lines, the grand total and the customer’s name are appended:
$pedido .= "<br><br>Total: " . $total;
$pedido .= "<br><br>De: " . $nombre;
The resulting message is sent with $mail->Body = $pedido using PHPMailer’s HTML body. A plain-text fallback is provided in $mail->AltBody. The email is sent to:
  • Customer — the address entered in the summary form, addressed as "Compra a nombre {$nombre}".
  • Store copy[email protected], addressed as "Copia de Pedido".

Customizing PayPal

The following hidden fields inside the PayPal form in final.php should be updated before going live:
FieldCurrent default valueWhat to change it to
business[email protected]Your PayPal merchant account email address
item_nameYUME-TECYour store or product name shown on PayPal
item_numberFMYour internal order or SKU reference code
no_shipping0Set to 1 to hide shipping address on PayPal
no_note1Set to 0 to allow buyer notes on PayPal
currency_codeUSDYour preferred ISO 4217 currency code
lcESThe two-letter locale for the PayPal UI
bnPP-BuyNowBFPayPal button source identifier
The amount field is always injected dynamically from $total and must not be hardcoded.

Build docs developers (and LLMs) love