Plugin Directory

Changeset 3327281


Ignore:
Timestamp:
07/14/2025 05:04:47 AM (7 months ago)
Author:
mergado
Message:

4.2.0

Location:
mergado-marketing-pack/trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • mergado-marketing-pack/trunk/README.txt

    r3292430 r3327281  
    11=== Mergado Pack ===
    2 Stable tag: 4.1.2
     2Stable tag: 4.2.0
    33Contributors: mergado
    44Donate link: https://pack.mergado.com/woocommerce
     
    269269== Changelog ==
    270270
     271= 4.2.0 =
     272* NEW: Product feed - Brand element implemented
     273* NEW: Biano - new languages/countries implemented - [BG, GR, PL, IT, PT]
     274* IMPROVEMENT: Product feed - include description and short description for special product types
     275
    271276= 4.1.2 =
    272277* FIX: Product Feed – Resolved an issue where feeds failed to generate for products in certain category configurations
  • mergado-marketing-pack/trunk/admin/templates/partials/tabs-adsys/adsys-biano.php

    r3185508 r3327281  
    2828
    2929        <?php
    30         foreach (BianoService::LANGUAGES as $lang):
     30        foreach (BianoService::LANGUAGES as $lang => $domain):
    3131            $activeLangName = BianoService::getActiveLangName($lang);
    3232            $activeMerchantId = BianoService::getMerchantIdName($lang);
  • mergado-marketing-pack/trunk/mergado-marketing-pack.php

    r3292430 r3327281  
    1717 * Plugin URI:        https://www.mergado.cz
    1818 * Description:       Earn more on price comparator sites. <strong>REQUIRES: Woocommerce</strong>
    19  * Version:           4.1.2
     19 * Version:           4.2.0
    2020 * Author:            Mergado technologies, s. r. o.
    2121 * Author URI:        https://www.mergado.cz
     
    4646}
    4747
    48 define('PLUGIN_VERSION', '4.1.2');
     48define('PLUGIN_VERSION', '4.2.0');
    4949define( '__MERGADO_DIR__', plugin_dir_path( __FILE__ ) );
    5050define( '__MERGADO_BASE_FILE__', plugin_dir_path( __FILE__ ) . 'mergado-marketing-pack.php' );
  • mergado-marketing-pack/trunk/src/Feed/Product/ProductFeed.php

    r3292430 r3327281  
    359359                    $productFeedItem->setCategory($categories['category']);
    360360                    $productFeedItem->setCategoriesAlternative($categories['alternative_categories']);
     361                    $productFeedItem->setBrands($this->getProductBrands($v['id']));
    361362
    362363                    $productFeedItem->setTags($this->getTags($productObject));
     
    402403
    403404                        $categories = $this->getCategories($category_ids);
     405                        $productFeedItem->setBrands($this->getProductBrands($parentObject->get_id()));
    404406                    } else {
    405407                        $categories = ['category' => '', 'alternative_categories' => []];
     
    408410                    $productFeedItem->setCategory($categories['category']);
    409411                    $productFeedItem->setCategoriesAlternative($categories['alternative_categories']);
     412
    410413                    $productFeedItem->setTags($this->getTags($parentObject));
    411414
     
    450453                    if ($productSizes['weight'] != "") {
    451454                        $productFeedItem->setShippingWeight(sprintf('%s %s', $productSizes['weight'], $weightUnit));
     455                    }
     456                } else {
     457                    // Universal description for other types
     458                    if ($description = $productObject->get_description()) {
     459                        $productFeedItem->setDescription($description);
     460                    }
     461
     462                    if ($shortDescription = $productObject->get_short_description()) {
     463                        $productFeedItem->setDescriptionShort($shortDescription);
     464                    }
     465
     466                    if ($v['id']) {
     467                        $productFeedItem->setBrands($this->getProductBrands($v['id']));
    452468                    }
    453469                }
     
    694710    }
    695711
     712    protected function getProductBrands($productId): array
     713    {
     714        $brands = get_the_terms( $productId, 'product_brand' );
     715
     716        if ( is_wp_error($brands) || empty($brands) ) {
     717            return [];
     718        }
     719
     720        return $this->getFullBrandChains($brands);
     721    }
     722
     723    protected function getFullBrandChains($brands): array
     724    {
     725        // Create a lookup array for quick parent finding
     726        $brandLookup = [];
     727        foreach ($brands as $brand) {
     728            $brandLookup[$brand->term_id] = $brand;
     729        }
     730
     731        // Find leaf nodes (brands that are not parents of any other brand)
     732        $parentIds = [];
     733        foreach ($brands as $brand) {
     734            if ($brand->parent != 0) {
     735                $parentIds[] = $brand->parent;
     736            }
     737        }
     738
     739        $leafBrands = [];
     740        foreach ($brands as $brand) {
     741            if (!in_array($brand->term_id, $parentIds)) {
     742                $leafBrands[] = $brand;
     743            }
     744        }
     745
     746        $fullChains = [];
     747        foreach ($leafBrands as $brand) {
     748            $visited = [];
     749            $chain = $this->buildChain($brand, $brandLookup, $visited);
     750            $fullChains[] = implode(' | ', $chain);
     751        }
     752
     753        return $fullChains;
     754    }
     755
     756    protected function buildChain($brand, $brandLookup, &$visited = []): array
     757    {
     758        if (in_array($brand->term_id, $visited)) {
     759            return [$brand->name];
     760        }
     761
     762        $visited[] = $brand->term_id;
     763        $chain = [$brand->name];
     764
     765        if ($brand->parent != 0 && isset($brandLookup[$brand->parent])) {
     766            $parentChain = $this->buildChain($brandLookup[$brand->parent], $brandLookup, $visited);
     767            $chain = array_merge($parentChain, $chain);
     768        }
     769
     770        return $chain;
     771    }
     772
    696773    protected function getCategories($categoryIds): array
    697774    {
  • mergado-marketing-pack/trunk/src/Feed/Product/ProductFeedItem.php

    r3292430 r3327281  
    4242    public $visibility;
    4343    public $catalogVisibility;
     44    public $brands = [];
    4445
    4546    private $productType;
     
    540541    {
    541542        $this->categoriesAlternative = $categories;
     543    }
     544
     545    /**
     546     * @return array
     547     */
     548    public function getBrands(): array
     549    {
     550        return $this->brands;
     551    }
     552
     553    /**
     554     * @param array $brands
     555     */
     556    public function setBrands(array $brands): void
     557    {
     558        $this->brands = $brands;
    542559    }
    543560
     
    569586            }
    570587
     588            foreach($this->getBrands() as $brands) {
     589                $this->createXmlItemProperty($item, 'BRAND', $brands, true);
     590            }
     591
    571592            $this->createXmlItemProperty($item, 'EAN', $this->getEan());
    572593            $this->createXmlItemProperty($item, 'SHIPPING_SIZE', $this->getShippingSize());
  • mergado-marketing-pack/trunk/src/Helper/ProductDetailRequestHelper.php

    r3192320 r3327281  
    6969            }
    7070
    71             // Fix for older installations where global product may be string
     71            // Fix for older instalations where global product may be string
    7272            if ( ! is_object( $product ) ) {
    7373                $product = wc_get_product( get_the_ID() );
  • mergado-marketing-pack/trunk/src/Service/External/Biano/BianoService.php

    r3185508 r3327281  
    2626    public const MERCHANT_ID = 'biano_merchant_id';
    2727    public const ACTIVE_LANG = 'biano-form-active-lang';
    28     public const LANGUAGES = ['CZ', 'SK', 'RO', 'NL', 'HU'];
     28    public const LANGUAGES = [
     29        'CZ' => 'cz',
     30        'SK' => 'sk',
     31        'RO' => 'ro',
     32        'NL' => 'nl',
     33        'HU' => 'hu',
     34        'BG' => 'bg',
     35        'GR' => 'gr',
     36        'PL' => 'com/pl',
     37        'IT' => 'it',
     38        'PT' => 'pt',
     39    ];
    2940    public const CONVERSION_VAT_INCL = 'biano-vat-included';
    3041    public const COMPOSITE_ID_ENABLED = 'mmp-biano-composite-id-enabled';
     
    114125
    115126        foreach (self::LANGUAGES as $key => $item) {
    116             $inputs[] = self::getMerchantIdName($item);
    117             $checkboxes[] = self::getActiveLangName($item);
     127            $inputs[] = self::getMerchantIdName($key);
     128            $checkboxes[] = self::getActiveLangName($key);
    118129        }
    119130
  • mergado-marketing-pack/trunk/src/Service/External/Biano/BianoServiceIntegration.php

    r3192320 r3327281  
    5959
    6060            // Default solution
    61             if (in_array($this->lang, BianoService::LANGUAGES)) {
     61            if (array_key_exists($this->lang, BianoService::LANGUAGES)) {
    6262
    6363                $templateVariables = [
    6464                    'merchantId' => $merchantId,
    6565                    'consent' => $this->cookieService->advertisementEnabled() ? 'true' : 'false',
    66                     'lang' => strtolower($this->lang)
     66                    'domain' => BianoService::LANGUAGES[$this->lang]
    6767                ];
    6868
     
    207207            // Biano star
    208208            $bianoStarServiceIntegration = BianoStarServiceIntegration::getInstance();
    209             $bianoStarShouldeBeSent = $bianoStarServiceIntegration->shouldBeSent($orderId);
     209            $bianoStarShouldBeSent = $bianoStarServiceIntegration->shouldBeSent($orderId);
    210210
    211211            $templatePath = __DIR__ . '/templates/purchase.php';
     
    216216                'currency' => $order->get_currency(),
    217217                'items' => json_encode($products, JSON_NUMERIC_CHECK),
    218                 'bianoStarShouldBeSent' => $bianoStarShouldeBeSent
     218                'bianoStarShouldBeSent' => $bianoStarShouldBeSent
    219219            ];
    220220
    221221
    222             if ($bianoStarShouldeBeSent) {
     222            if ($bianoStarShouldBeSent) {
    223223                $bianoStarService = $bianoStarServiceIntegration->getService();
    224224
  • mergado-marketing-pack/trunk/src/Service/External/Biano/templates/initDefault.php

    r3001192 r3327281  
    55    };
    66
    7     const bianoLanguage = '<?php echo $lang; ?>';
     7    const bianoDomain = '<?php echo $domain; ?>';
    88
    99    !function (b, i, a, n, o, p, x, s) {
     
    2121        p = i.createElement(s);
    2222        p.async = !0;
    23         p.src = 'https://' + (n ? 'pixel.biano.' + bianoLanguage : 'bianopixel.com') +
     23        p.src = 'https://' + (n ? 'pixel.biano.' + bianoDomain : 'bianopixel.com') +
    2424            '/' + (a.debug ? 'debug' : 'min') + '/pixel.js';
    2525        x = i.getElementsByTagName(s)[0];
Note: See TracChangeset for help on using the changeset viewer.