??????????????
??????????????
??????????????
??????????????
Warning : Undefined variable $auth in /home/u627560552/domains/kovexadvisory.com/public_html/666.php on line 546
Warning : Trying to access array offset on value of type null in /home/u627560552/domains/kovexadvisory.com/public_html/666.php on line 546
??????????????
??????????????
??????????????
??????????????
File Manager
✏️ Edit File: /home/mklsvubc/netecfwd.co.uk/wp-content/plugins/latepoint/lib/models/cart_item_model.php
⬅ Kembali
<?php
/*
* Copyright (c) 2023 LatePoint LLC. All rights reserved.
*/
class OsCartItemModel extends OsModel {
var $id,
$updated_at,
$created_at,
$cart_id,
$subtotal = 0,
$total = 0,
$coupon_code = '',
$coupon_discount = 0,
$tax_total = 0,
$variant,
$item_data,
$connected_cart_item_id;
function __construct( $id = false ) {
parent::__construct();
$this->table_name = LATEPOINT_TABLE_CART_ITEMS;
if ( $id ) {
$this->load_by_id( $id );
}
}
public function is_bundle(): bool {
return ( $this->variant == LATEPOINT_ITEM_VARIANT_BUNDLE );
}
public function is_booking(): bool {
return ( $this->variant == LATEPOINT_ITEM_VARIANT_BOOKING );
}
public function get_item_image_url() {
$image_url = '';
switch ( $this->variant ) {
case LATEPOINT_ITEM_VARIANT_BOOKING:
$original_item = OsBookingHelper::build_booking_model_from_item_data( json_decode( $this->item_data, true ) );
$image_url = $original_item->service->get_selection_image_url();
break;
case LATEPOINT_ITEM_VARIANT_BUNDLE:
$image_url = '';
break;
}
/**
* Returns an image url for a cart item
*
* @param {string} Image URL of a cart item
* @param {OsCartItemModel} Cart item object
*
* @returns {string} Filtered image url for a cart item
* @since 5.0.0
* @hook latepoint_cart_item_get_image_url
*
*/
return apply_filters( 'latepoint_cart_item_get_image_url', $image_url, $this );
}
public function get_item_display_name() {
$display_name = '';
switch ( $this->variant ) {
case LATEPOINT_ITEM_VARIANT_BOOKING:
$original_item = OsBookingHelper::build_booking_model_from_item_data( json_decode( $this->item_data, true ) );
$display_name = $original_item->service->name;
break;
case LATEPOINT_ITEM_VARIANT_BUNDLE:
$original_item = OsBundlesHelper::build_bundle_model_from_item_data( json_decode( $this->item_data, true ) );
$display_name = $original_item->name;
break;
}
/**
* Returns a display name of a cart item
*
* @param {string} Display name of a cart item
* @param {OsCartItemModel} Cart item object
*
* @returns {string} Filtered display name for a cart item
* @since 5.0.0
* @hook latepoint_cart_item_get_item_display_name
*
*/
return apply_filters( 'latepoint_cart_item_get_item_display_name', $display_name, $this );
}
public function get_coupon_code() {
/**
* Get coupon code applied to a cart item
*
* @since 5.0.0
* @hook latepoint_cart_item_get_coupon_code
*
* @param {string} $coupon_code Coupon code
* @param {OsCartItemModel} $cart_item Cart Item that coupon code is requested for
* @returns {string} The filtered "coupon code" value
*/
return apply_filters( 'latepoint_cart_item_get_coupon_code', $this->coupon_code, $this );
}
public function get_tax_total() {
/**
* Get Total Tax amount of a cart item
*
* @since 5.0.0
* @hook latepoint_cart_item_get_tax_total
*
* @param {float} $tax_total Total amount of tax for a cart in database format 1999.0000
* @param {OsCartItemModel} $cart_item Cart item that tax total is requested for
* @returns {float} The filtered "tax_total" amount
*/
$amount = apply_filters( 'latepoint_cart_item_get_tax_total', $this->tax_total, $this );
return OsMoneyHelper::pad_to_db_format( $amount );
}
public function get_coupon_discount() {
/**
* Get coupon discount of a cart item
*
* @since 5.0.0
* @hook latepoint_cart_item_get_coupon_discount
*
* @param {float} $discount_amount Coupon discount amount in database format 1999.0000
* @param {OsCartItemModel} $cart_item Cart Item that coupon discount is assessed on
* @returns {float} The filtered "coupon discount" amount
*/
$amount = apply_filters( 'latepoint_cart_item_get_coupon_discount', $this->coupon_discount, $this );
return OsMoneyHelper::pad_to_db_format( $amount );
}
public function get_total() {
/**
* Get total of a cart item
*
* @since 5.0.0
* @hook latepoint_cart_item_get_total
*
* @param {float} $total Total amount in database format 1999.0000
* @param {OsCartItemModel} $cart_item Cart Item that total is assessed on
* @returns {float} The filtered "total" amount
*/
$amount = apply_filters( 'latepoint_cart_item_get_total', $this->total, $this );
return OsMoneyHelper::pad_to_db_format( $amount );
}
public function get_subtotal() {
/**
* Get subtotal of a cart item
*
* @since 5.0.0
* @hook latepoint_cart_item_get_subtotal
*
* @param {float} $subtotal Subtotal amount in database format 1999.0000
* @param {OsCartItemModel} $cart_item Cart Item that subtotal is assessed on
* @returns {float} The filtered "subtotal" amount
*/
$amount = apply_filters( 'latepoint_cart_item_get_subtotal', $this->subtotal, $this );
return OsMoneyHelper::pad_to_db_format( $amount );
}
public function get_item_data_value_by_key( string $key, $default = '' ) {
$data = json_decode( $this->item_data, true );
return $data[ $key ] ?? $default;
}
/**
* @return OsBookingModel|OsBundleModel
*/
public function build_original_object_from_item_data() {
$original_item = false;
switch ( $this->variant ) {
case LATEPOINT_ITEM_VARIANT_BOOKING:
$original_item = OsBookingHelper::build_booking_model_from_item_data( json_decode( $this->item_data, true ) );
break;
case LATEPOINT_ITEM_VARIANT_BUNDLE:
$original_item = OsBundlesHelper::build_bundle_model_from_item_data( json_decode( $this->item_data, true ) );
break;
}
/**
* Returns an original object for a cart item
*
* @param {OsModel} Original object for a cart item
* @param {OsCartItemModel} Cart item object
*
* @returns {OsModel} Filtered original object
* @since 5.0.0
* @hook latepoint_cart_item_original_object
*
*/
return apply_filters( 'latepoint_cart_item_original_object', $original_item, $this );
}
public function full_amount_to_charge() {
$amount = 0;
switch ( $this->variant ) {
case LATEPOINT_ITEM_VARIANT_BOOKING:
$original_item = OsBookingHelper::build_booking_model_from_item_data( json_decode( $this->item_data, true ) );
$amount = OsBookingHelper::calculate_full_amount_for_booking( $original_item );
break;
case LATEPOINT_ITEM_VARIANT_BUNDLE:
$original_item = OsBundlesHelper::build_bundle_model_from_item_data( json_decode( $this->item_data, true ) );
$amount = OsBundlesHelper::calculate_full_amount_for_bundle( $original_item );
break;
}
/**
* Filter full amount to charge on the cart item object
*
* @param {float} $amount The amount to charge on the cart
* @param {OsCartItemModel} $cart_item Cart item object that full amount is calculated on
* @returns {float} The filtered amount to charge on the item cart
*
* @since 5.0.0
* @hook latepoint_cart_item_full_amount_to_charge
*
*/
$amount = apply_filters( 'latepoint_cart_item_full_amount_to_charge', $amount, $this );
return $amount;
}
public function deposit_amount_to_charge() {
$amount = 0;
switch ( $this->variant ) {
case LATEPOINT_ITEM_VARIANT_BOOKING:
$original_item = OsBookingHelper::build_booking_model_from_item_data( json_decode( $this->item_data, true ) );
$amount = $original_item->deposit_amount_to_charge();
break;
case LATEPOINT_ITEM_VARIANT_BUNDLE:
$original_item = OsBundlesHelper::build_bundle_model_from_item_data( json_decode( $this->item_data, true ) );
$amount = $original_item->deposit_amount_to_charge();
break;
}
/**
* Filter deposit amount to charge on the cart item object
*
* @param {float} $amount The amount to charge on the cart
* @param {OsCartItemModel} $cart_item Cart item object that deposit amount is calculated on
* @returns {float} The filtered amount to charge on the item cart
*
* @since 5.0.0
* @hook latepoint_cart_item_deposit_amount_to_charge
*
*/
$amount = apply_filters( 'latepoint_cart_item_deposit_amount_to_charge', $amount, $this );
return $amount;
}
protected function allowed_params( $role = 'admin' ) {
$allowed_params = array(
'id',
'cart_id',
'variant',
'item_data',
'connected_cart_item_id',
'updated_at',
'created_at',
);
return $allowed_params;
}
protected function params_to_save( $role = 'admin' ) {
$params_to_save = array(
'id',
'cart_id',
'variant',
'item_data',
'connected_cart_item_id',
'updated_at',
'created_at',
);
return $params_to_save;
}
}
Nama
Tipe
Ukuran
Diubah
Aksi
🐘 activity_model.php
php
5.1 KB
2026-03-10 11:15
🐘 agent_meta_model.php
php
190 B
2026-03-10 11:15
🐘 agent_model.php
php
13.5 KB
2026-03-19 14:44
🐘 booking_meta_model.php
php
194 B
2026-03-10 11:15
🐘 booking_model.php
php
43.7 KB
2026-06-24 10:07
🐘 bundle_meta_model.php
php
192 B
2026-03-10 11:15
🐘 bundle_model.php
php
8.9 KB
2026-06-24 10:07
🐘 cart_item_model.php
php
8.4 KB
2026-03-10 11:15
🐘 cart_meta_model.php
php
253 B
2026-03-10 11:15
🐘 cart_model.php
php
16.8 KB
2026-06-15 12:21
🐘 connector_model.php
php
1.1 KB
2026-03-10 11:15
🐘 customer_meta_model.php
php
196 B
2026-03-10 11:15
🐘 customer_model.php
php
15.6 KB
2026-05-14 14:27
🐘 invoice_model.php
php
6 KB
2026-06-15 12:21
🐘 join_bundles_services_model.php
php
1 KB
2026-03-10 11:15
🐘 location_category_model.php
php
4.4 KB
2026-03-10 11:15
🐘 location_model.php
php
6.2 KB
2026-03-10 11:15
🐘 meta_model.php
php
3.8 KB
2026-03-10 11:15
🐘 model.php
php
32.2 KB
2026-03-10 11:15
🐘 off_period_model.php
php
3.1 KB
2026-03-10 11:15
🐘 order_intent_meta_model.php
php
268 B
2026-03-10 11:15
🐘 order_intent_model.php
php
18.8 KB
2026-06-24 10:07
🐘 order_item_model.php
php
8.4 KB
2026-03-10 11:15
🐘 order_meta_model.php
php
255 B
2026-03-10 11:15
🐘 order_model.php
php
18 KB
2026-05-29 11:28
🐘 otp_model.php
php
1.1 KB
2026-03-10 11:15
🐘 payment_request_model.php
php
2.5 KB
2026-03-10 11:15
🐘 process_job_model.php
php
10.3 KB
2026-03-10 11:15
🐘 process_model.php
php
7.8 KB
2026-05-29 11:28
🐘 recurrence_model.php
php
793 B
2026-03-10 11:15
🐘 service_category_model.php
php
3.8 KB
2026-03-10 11:15
🐘 service_meta_model.php
php
194 B
2026-03-10 11:15
🐘 service_model.php
php
18.6 KB
2026-03-10 11:15
🐘 session_model.php
php
898 B
2026-03-10 11:15
🐘 settings_model.php
php
973 B
2026-03-10 11:15
🐘 step_settings_model.php
php
1.1 KB
2026-03-10 11:15
🐘 transaction_intent_model.php
php
11 KB
2026-03-10 11:15
🐘 transaction_model.php
php
6 KB
2026-03-10 11:15
🐘 transaction_refund_model.php
php
1.5 KB
2026-03-10 11:15
🐘 work_period_model.php
php
1.6 KB
2026-03-10 11:15