You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification
//First use of image, get info
$type = strtolower($type);
if ($type == '') {
$type = TCPDF_IMAGES::getImageFileType($file, $imsize);
} elseif ($type == 'jpg') {
$type = 'jpeg';
}
if ($type === 'webp') {
$webp_tmp = K_PATH_CACHE . '__tcpdf_' . $this->file_id . '_webp2png_' . md5($file);
if (!is_file($webp_tmp)) {
// Prefer GD if it supports WebP
if (function_exists('imagecreatefromwebp')) {
$src = @imagecreatefromwebp($file);
if ($src) {
$wpx = imagesx($src);
$hpx = imagesy($src);
// Create truecolor target with alpha
$dst = imagecreatetruecolor($wpx, $hpx);
imagealphablending($dst, false);
imagesavealpha($dst, true);
// Fully transparent background
$transparent = imagecolorallocatealpha($dst, 255, 255, 255, 127);
imagefill($dst, 0, 0, $transparent);
// Copy original WebP onto transparent canvas
imagecopy($dst, $src, 0, 0, 0, 0, $wpx, $hpx);
// Save as PNG (with alpha)
imagepng($dst, $webp_tmp);
imagedestroy($dst);
imagedestroy($src);
}
}
// Fallback: use Imagick if available
if (!is_file($webp_tmp) && extension_loaded('imagick')) {
try {
$img = new Imagick();
$img->readImage($file);
// keep alpha, just change container format
$img->setImageFormat('png');
$img->writeImage($webp_tmp);
$img->destroy();
} catch (Exception $e) {
// If conversion fails, silently fall back to original behavior
}
}
}
if (is_file($webp_tmp)) {
$file = $webp_tmp;
$type = 'png';
$imsize = @getimagesize($file);
}
}

if (!empty($variant)) {
$variant = $this->roundInternal($this->_currencyDisplay->convertCurrencyTo((int) $this->productCurrency, doubleval($variant),true));
$basePriceShopCurrency = $basePriceShopCurrency + $variant;
$this->productPrices['basePrice'] = $this->productPrices['basePriceVariant'] = $basePriceShopCurrency;
} Delete it completely.if (empty($this->productPrices['basePriceVariant'])) {
$this->productPrices['basePriceVariant'] = $this->productPrices['basePrice'];
}
/* ============================================================
FIX: Correct handling of variant/modifier prices in VirtueMart
------------------------------------------------------------
VM incorrectly adds variant price to the base product price
BEFORE applying discount rules. This causes the variant to be
discounted, which is mathematically wrong.
Here we calculate the variant separately and add it *after*
discounts and tax calculations – which is the correct logic.
============================================================ */
// 1. Convert variant price to shop currency but DO NOT add it to base price
$variantNet = 0.0;
if (!empty($variant)) {
// Variant net amount converted to shop currency
$variantNet = $this->roundInternal(
$this->_currencyDisplay->convertCurrencyTo(
(int)$this->productCurrency,
(double)$variant,
true
)
);
}
// 2. After VM finished discount calculations, add the variant
if (!empty($variantNet)) {
// Calculate VAT on variant separately
$variantGross = $variantNet;
// Apply VAT/TAX rules to variant
if (!empty($this->rules['Tax'])) {
$variantGross = $this->roundInternal(
$this->executeCalculation($this->rules['Tax'], $variantGross, true),
'salesPrice'
);
}
if (!empty($this->rules['VatTax'])) {
$variantGross = $this->roundInternal(
$this->executeCalculation($this->rules['VatTax'], $variantGross, true),
'salesPrice'
);
}
// Update priceWithoutTax (variantNet)
if (isset($this->productPrices['priceWithoutTax'])) {
$this->productPrices['priceWithoutTax'] += $variantNet;
}
// Update VAT amount (difference between gross and net)
if (isset($this->productPrices['taxAmount'])) {
$this->productPrices['taxAmount'] += ($variantGross - $variantNet);
}
// Add variant to final salesPrice (correct placement)
if (isset($this->productPrices['salesPrice'])) {
$this->productPrices['salesPrice'] += $variantGross;
}
// Add variant to unit price if packaging is used
if (!empty($product->product_packaging) && $product->product_packaging != '0.0000') {
$this->productPrices['unitPrice'] = $this->productPrices['salesPrice'] / $product->product_packaging;
}
// Save modifier for output
$this->productPrices['variantModification'] = $variantNet;
}
/* ========================= END OF FIX ============================ */
Page created in 0.044 seconds with 9 queries.