> ## Documentation Index
> Fetch the complete documentation index at: https://docs.getlecker.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Introduction

> Controller for handling shop-related functionality

The `Shop` class is a controller that manages various shop-related operations, including customer registration, cart management, checkout process, and order processing.

## Class Properties

<ResponseField name="shop" type="null">
  Protected property to store shop-related data.
</ResponseField>

<ResponseField name="stripe_secret" type="string">
  Stripe secret key for payment processing.
</ResponseField>

<ResponseField name="stripe_pk" type="string">
  Stripe public key for payment processing.
</ResponseField>

<ResponseField name="bill_prefix" type="string">
  Prefix used for bill identification.
</ResponseField>

<ResponseField name="abei_token" type="string">
  Token for ABEI API authentication.
</ResponseField>

<ResponseField name="abei_url" type="string">
  URL for ABEI API endpoint.
</ResponseField>

## Constructor

The constructor initializes the class, loads necessary models, and sets up important properties.

## Methods

### sendABEI

<ParamField path="order_id" type="integer">
  The ID of the order to be sent to ABEI.
</ParamField>

Sends order data to the ABEI API. This method is currently not fully implemented.

### customer\_registration

Loads the customer registration view.

### register\_customer

Handles the customer registration process.

<ResponseField name="success" type="boolean">
  Indicates whether the registration was successful.
</ResponseField>

<ResponseField name="msg" type="string">
  Message describing the result of the registration process.
</ResponseField>

### sendMailCustomerRegistration

<ParamField path="data" type="array">
  Customer registration data.
</ParamField>

<ParamField path="user_email" type="string">
  Email address of the registered customer.
</ParamField>

Sends a confirmation email to the newly registered customer.

### confirm\_registration

<ParamField path="token" type="string">
  Confirmation token for the registration.
</ParamField>

Confirms a customer's registration using the provided token.

### customer\_login

Handles customer login process.

<ResponseField name="success" type="boolean">
  Indicates whether the login was successful.
</ResponseField>

<ResponseField name="msg" type="string">
  Message describing the result of the login process.
</ResponseField>

### customer\_logout

Handles customer logout process.

<ResponseField name="success" type="boolean">
  Always returns true upon successful logout.
</ResponseField>

### removePromoCode

Removes the applied promo code from the current session and cart.

### addPromoCode

<ParamField path="promo_code" type="string">
  The promo code to be applied.
</ParamField>

Applies a promo code to the current session.

<ResponseField name="success" type="boolean">
  Indicates whether the promo code was successfully applied.
</ResponseField>

<ResponseField name="msg" type="string">
  Message describing the result of applying the promo code.
</ResponseField>

### stripeWebhook

Handles Stripe webhook events for payment processing.

### stripeInit

<ParamField path="amount" type="integer">
  The amount to be charged in cents.
</ParamField>

<ParamField path="order_id" type="integer">
  The ID of the order being processed.
</ParamField>

<ParamField path="treat_redirect_token" type="string">
  A token for redirecting after payment.
</ParamField>

Initializes a Stripe Checkout session.

<ResponseField name="url" type="string">
  The URL for the Stripe Checkout session.
</ResponseField>

### load\_view

<ParamField path="view" type="string">
  The name of the view to be loaded.
</ParamField>

<ParamField path="viewdata" type="array">
  Data to be passed to the view.
</ParamField>

Loads a view with common data and settings.

### getRandomInteger

<ParamField path="min" type="integer">
  The minimum value of the range.
</ParamField>

<ParamField path="max" type="integer">
  The maximum value of the range.
</ParamField>

Generates a random integer within the specified range.

<ResponseField name="integer" type="integer">
  The generated random integer.
</ResponseField>

### cart\_view

Loads the cart view with current cart data and applied promotions.

### checkout

Processes the checkout form submission and initiates the payment process.

### clearCart

Clears the current cart and removes any applied promo code.

### getCartItemCount

<ParamField path="message" type="string" optional>
  Optional message to be included in the response.
</ParamField>

Returns the current number of items in the cart.

<ResponseField name="success" type="boolean">
  Always returns true.
</ResponseField>

<ResponseField name="message" type="string">
  The optional message passed to the method.
</ResponseField>

<ResponseField name="count" type="integer">
  The number of items in the cart.
</ResponseField>

### getCartTotal

Returns the total value of items in the cart.

<ResponseField name="total" type="string">
  The total value of the cart, formatted as a string with two decimal places.
</ResponseField>

### removeFromCart

<ParamField path="rowId" type="string">
  The row ID of the item to be removed from the cart.
</ParamField>

Removes an item from the cart.

<ResponseField name="success" type="boolean">
  Always returns true.
</ResponseField>

<ResponseField name="rowid" type="string">
  The row ID of the removed item.
</ResponseField>

<ResponseField name="count" type="integer">
  Always returns 0.
</ResponseField>

<ResponseField name="total" type="string">
  The new total value of the cart after removal.
</ResponseField>

### addToCart

Adds an item to the cart.

<ParamField path="sid" type="integer">
  The ID of the product to be added.
</ParamField>

<ParamField path="qty" type="integer">
  The quantity of the product to be added.
</ParamField>

<ParamField path="type" type="string">
  The type of the product being added.
</ParamField>

### updateItemCartQty

Updates the quantity of an item in the cart.

<ParamField path="rowId" type="string">
  The row ID of the item to be updated.
</ParamField>

<ParamField path="change" type="integer">
  The change in quantity (positive or negative).
</ParamField>

<ResponseField name="success" type="boolean">
  Always returns true.
</ResponseField>

<ResponseField name="rowid" type="string">
  The row ID of the updated item.
</ResponseField>

<ResponseField name="count" type="integer">
  The new quantity of the item.
</ResponseField>

<ResponseField name="price" type="string">
  The new total price for this item.
</ResponseField>

<ResponseField name="price_net" type="string">
  The new total net price for this item.
</ResponseField>

<ResponseField name="price_tax" type="string">
  The new total tax for this item.
</ResponseField>

<ResponseField name="total" type="string">
  The new total value of the cart.
</ResponseField>

### success

Handles the successful payment process.

### notification

Handles payment notification process (not used in Stripe integration).

### cancel

Handles cancelled payment process.

### error

Handles payment error process.

### pending

Handles pending payment process.

### shop\_response

<ParamField path="msg" type="string">
  The message to be displayed in the response.
</ParamField>

Loads the shop response view with the given message.

### sendOrderConfirmation

<ParamField path="order_id" type="integer">
  The ID of the order to be confirmed.
</ParamField>

<ParamField path="amephias_response" type="string">
  The response from Amephias system.
</ParamField>

<ParamField path="has_ticket" type="boolean">
  Indicates whether the order includes a ticket.
</ParamField>

Sends an order confirmation email to the shop.

### sendOrderCustomer

<ParamField path="order_id" type="integer">
  The ID of the order to be sent to the customer.
</ParamField>

Sends an order confirmation email to the customer.

### create\_pdf\_mail\_new

Creates a PDF for a new order.

### create\_pdf\_mail

Creates a PDF for an order (older version).

### create\_pdf\_bill

Creates a PDF bill for an order.

### create\_pdf\_bill\_mail

Creates a PDF bill for an order to be sent via email.

### dompdf\_test

Generates a test PDF using dompdf library.

### dompdf\_test\_save\_to\_file

Generates a test PDF using dompdf library and saves it to a file.
