WEB SYSTEMS PRO
E-commerce platform
€29.80

* Net price (excluding VAT)

SKU:WSP-925-PL
License
Web Systems Pro
Version
3.0.1.1.wsp
Update
12/27/2024


How to create your own product "block" from a collection

If you want to create your own separate block with the same appearance as cross/upselling, you need to copy part of the code from crossselling, then replace the array and the header.
For the Default theme, it will look like this:

Was:

<!-- RELATED PRODUCTS -->
{$upselling = $product->upSelling(12)}
{$crossselling = $product->crossSelling(12)}

{if $upselling || $crossselling}
    <div class="product-info">

        {if $crossselling}
            <section class="related">
                <h3>{sprintf('Customers who bought %s also bought', $product.name|escape)}</h3>
                {include file="list-thumbs-mini.html" products=$crossselling ulclass="related-bxslider"}
            </section>
        {/if}

        {if $upselling}
            <section class="related">
                <h3>
                    See also
                    {$compare_ids = array_merge(array($product.id), array_keys($upselling))}
                    <input type="button" onClick="javascript:window.location='{$wa->getUrl('/frontend/compare', ['id' => implode(',', $compare_ids)])}';" value="Compare all" class="gray" />

                </h3>
                {include file="list-thumbs-mini.html" products=$upselling ulclass="related-bxslider"}
            </section>
        {/if}

    </div>
{/if}


Became:

<!-- RELATED PRODUCTS -->
{$upselling = $product->upSelling(12)}
{$crossselling = $product->crossSelling(12)}
{$mycollection = shopStek37Plugin::get($product.id, 12)}

{if $upselling || $crossselling || $mycollection}
    <div class="product-info">

        {if $crossselling}
            <section class="related">
                <h3>{sprintf('Customers who bought %s also bought', $product.name|escape)}</h3>
                {include file="list-thumbs-mini.html" products=$crossselling ulclass="related-bxslider"}
            </section>
        {/if}

        {if $upselling}
            <section class="related">
                <h3>
                    See also
                    {$compare_ids = array_merge(array($product.id), array_keys($upselling))}
                    <input type="button" onClick="javascript:window.location='{$wa->getUrl('/frontend/compare', ['id' => implode(',', $compare_ids)])}';" value="Compare all" class="gray" />

                </h3>
                {include file="list-thumbs-mini.html" products=$upselling ulclass="related-bxslider"}
            </section>
        {/if}

        {if $mycollection}
            <section class="related">
                <h3>This is my additional collection </h3>
                {include file="list-thumbs-mini.html" products=$mycollection ulclass="related-bxslider"}
            </section>
        {/if}

    </div>
{/if}


What was done?

  1. Obtained the collection array:
    {$mycollection = shopStek37Plugin::get($product.id, 12)}
  2. Added a display condition for the related products block in case of having a custom collection:
    {if $upselling || $crossselling || $mycollection}
  3. Copied the crossselling block and changed the array and header inside it:
            {if $mycollection}
                <section class="related">
                    <h3>This is my additional collection</h3>
                    {include file="list-thumbs-mini.html" products=$mycollection ulclass="related-bxslider"}
                </section>
            {/if}


In most graphical themes, this block is implemented almost identically, with minor differences in HTML elements used, HTML class names, and the product list template used (list-thumbs-mini.html, list-thumbs.html, products-list.html, etc.).


How to add products from a collection to the cross/upselling sales list?

Changes are made in the product.html template. The code might look slightly different in various graphical themes, but the changes are applied in the same way.

In general, the helper for retrieving the group product array looks like this:

shopStek37Plugin::get($product.id, 12)

The helper receives the product ID (on the product page it is $product.id) and the product limit (12 in the example). If the limit is not set, all products in the collection will be retrieved.

To display products from the collection together with upselling products, find the code that retrieves the $upselling array in the template:

{$upselling = $product->upSelling(12)}

And replace this code with:

{$upselling = $product->upSelling(12) + shopStek37Plugin::get($product.id, 12)}

To display products from the collection together with crossselling products, find the code that retrieves the $crossselling array in the template:

{$crossselling = $product->crossSelling(12)}

And replace this code with:

{$crossselling = $product->crossSelling(12) + shopStek37Plugin::get($product.id, 12)}

In the same way, you can add products from a collection to any other product array/list.