item = $item;
$this->cart = $cart;
}
protected function getEventInfo()
{
return [
'item' => $this->item,
'cart' => $this->cart,
'product' => $this->product,
'variant' => $this->variant,
];
}
public function render()
{
$wrapperClassAttributes = [
'fct_line_item',
'fct_product_id_' . Arr::get($this->item, 'post_id', ''),
'fct_item_id_' . Arr::get($this->item, 'id', ''),
'fct_item_type_' . Arr::get($this->item, 'other_info.payment_type', ''),
];
if (Arr::get($this->item, 'featured_media')) {
$wrapperClassAttributes[] = 'fct_has_image';
}
$promoPriceOriginal = Arr::get($this->item, 'other_info.promo_price_original', 0);
if ($promoPriceOriginal && $promoPriceOriginal > $this->item['unit_price']) {
$promoPriceOriginal = $promoPriceOriginal * Arr::get($this->item, 'quantity', 1);
} else {
$promoPriceOriginal = '';
}
$couponDiscount = (int) Arr::get($this->item, 'coupon_discount', 0);
$lineTotal = (int) Arr::get($this->item, 'line_total', 0);
$subtotal = (int) Arr::get($this->item, 'subtotal', 0);
$hasCouponDiscount = $couponDiscount > 0 && $lineTotal < $subtotal;
?>
renderImage(); ?>
renderTitle(); ?>
renderChildVariants(); ?>
getEventInfo()); ?>
getEventInfo()); ?>
getEventInfo()); ?>
item, 'view_url', '');
$mainTitle = (string) Arr::get($this->item, 'post_title', '');
// The Cart model already resolves & appends variation_display_title on
// every cart item (Cart::getCartDataAttribute); fall back to the raw
// variation title for items it didn't decorate.
$subtitle = (string) Arr::get($this->item, 'variation_display_title', (string) Arr::get($this->item, 'title', ''));
$quantity = Arr::get($this->item, 'quantity', 1);
?>
getEventInfo()); ?>
1): ?>
x
-
maybeRenderPaymentTypeInfo(); ?>
maybeRenderPackageInfo(); ?>
getEventInfo()); ?>
item, 'featured_media');
if (!$image) {
$image = Vite::getAssetUrl('images/placeholder.svg');
}
$href = Arr::get($this->item, 'view_url', '');
$altText = sprintf(
/* translators: %s: product title */
__('Image of %s', 'fluent-cart'), Arr::get($this->item, 'title', __('product', 'fluent-cart')));
?>
item, 'other_info', []);
$paymentType = Arr::get($otherInfo, 'payment_type', '');
$itemPrice = Arr::get($this->item, 'unit_price', 0);
if (isset($this->item['recurring_discounts'])) {
$otherInfo['recurring_discounts'] = $this->item['recurring_discounts'];
}
if ($paymentType === 'subscription') {
$subscriptionInfo = Helper::generateSubscriptionInfo($otherInfo, $itemPrice);
$trialInfo = Helper::generateTrialInfo($otherInfo);
?>
true]); ?>
item, 'quantity', 1);
if ($quantity < 2) {
return;
}
?>
getEventInfo()); ?>
item, 'other_info.payment_type', '');
if ($paymentType !== 'subscription') {
return false;
}
$otherInfo = Arr::get($this->item, 'other_info', []);
$setupFeeInfo = Helper::generateSetupFeeInfo($otherInfo);
if (empty($setupFeeInfo)) {
return false;
}
return true;
}
protected function renderSetupFeeInfo()
{
$otherInfo = Arr::get($this->item, 'other_info', []);
$setupFeeInfo = Helper::generateSetupFeeInfo($otherInfo, true);
$setupFeeName = Arr::get($setupFeeInfo, 'signup_fee_name', '');
$setupFeePrice = Arr::get($setupFeeInfo, 'signup_fee_formatted', 0);
?>
item, 'fulfillment_type') !== 'physical') {
return;
}
$otherInfo = Arr::get($this->item, 'other_info', []);
if (!is_array($otherInfo)) {
return;
}
$packageSlug = Arr::get($otherInfo, 'package_slug', '');
$package = Helper::getPackageBySlug($packageSlug);
if (!$package) {
return;
}
$name = Arr::get($package, 'name', '');
$type = Arr::get($package, 'type', '');
$parts = [];
if ($name) {
$parts[] = $name;
}
$storeWeightUnit = Helper::shopConfig('weight_unit') ?: 'kg';
$productWeight = floatval(Arr::get($otherInfo, 'weight', 0));
$productWeightUnit = Arr::get($otherInfo, 'weight_unit', $storeWeightUnit);
$convertedProductWeight = Helper::convertWeight($productWeight, $productWeightUnit, $storeWeightUnit);
$packageWeight = floatval(Arr::get($package, 'weight', 0));
$packageWeightUnit = Arr::get($package, 'weight_unit', $storeWeightUnit);
$convertedPackageWeight = Helper::convertWeight($packageWeight, $packageWeightUnit, $storeWeightUnit);
$totalWeight = $convertedProductWeight + $convertedPackageWeight;
if ($totalWeight) {
$formatted = rtrim(rtrim(number_format($totalWeight, 2), '0'), '.');
$parts[] = $formatted . ' ' . $storeWeightUnit;
}
if (!$parts) {
return;
}
$icon = ShippingMethodsRender::getPackageTypeIcon($type ?: 'box');
?>
item, 'child_variants', []);
if (empty($childVariants)) {
return;
}
$total = count($childVariants);
?>