Product information in checkout/cart

Hi guys,

our online store is to be certified. So far so good. However, one point of the certification is that a product in the shopping cart and on the checkout again must have the essential points broken down.

e.g. for a t-shirt, the size and the color.
Or with a picture the size and the material
whatever is the relevant point

Is there a possibility (or a plugin) that selected fields and their content are displayed in the shopping cart and on the checkout. Currently “only” title and product code are displayed. I have not found a function that allows me to display additional fields.

Thank you.
Ronny

Since i also need this information in the e-mail notifications, i took a closer look at them. However, the respective variables do not seem to exist, which, for example, fall back on the detailed article description or the short description.

Is there any way to add these?

Currently “only” these variables exist:

{{ p.item_id }} {{ p.product_id }} {{ p.product_code }} {{ p.name }} {{ p.price }} {{ p.amount }} {{ p.product_status }} {{ p.product_url }} {{ p.deleted_product }} {{ p.discount }} {{ p.company_id }} {{ p.base_price }} {{ p.original_price }} {{ p.cart_id }} {{ p.tax }} {{ p.subtotal }} {{ p.display_subtotal }} {{ p.shipped_amount }} {{ p.shipment_amount }} {{ p.is_accessible }} {{ p.shared_product }} {{ p.unlimited_download }} {{ p.is_edp }} {{ p.edp_shipping }} {{ p.stored_price }} {{ p.counter }} {{ p.main_pair }} {{ p.image }} {{ p.options }} {{ p.raw.price }} {{ p.raw.original_price }} {{ p.raw.subtotal }} {{ p.raw.display_subtotal }} {{ p.raw.discount }} {{ p.raw.tax }} {{ p.raw.options }} {{ supplier.supplier_id }} {{ supplier.company_id }} {{ supplier.name }} {{ supplier.address }} {{ supplier.city }} {{ supplier.state }} {{ supplier.country }} {{ supplier.zipcode }} {{ supplier.email }} {{ supplier.phone }} {{ supplier.fax }}

Phew, lengthy communication. But ok. :face_with_diagonal_mouth:
Is there any hack/plugin to show product field in cart and checkout?

Have you tried?

{{ p.short_description }}

and

{{ p.full_description }}

?

Sometimes such tricks work

I think that has to be a PHP variable. Because the checkout-template (in / templates / blocks / checkout / products_in_cart.tpl) for products in cart looks like:

<div id="checkout_info_products_{$block.snapping_id}">
	<ul class="ty-order-products__list order-product-list">
	{hook name="block_checkout:cart_items"}
		{foreach from=$cart_products key="key" item="product" name="cart_products"}
			{hook name="block_checkout:cart_products"}
				{if !$cart.products.$key.extra.parent}
					<li class="ty-order-products__item clearfix">
						<a href="{"products.view?product_id=`$product.product_id`"|fn_url}" class="product-image ty-float-left ty-order-products__a">
							{include file="common/image.tpl" images=$product.main_pair image_width="67" image_height="67" class="primary active"}
						</a>
						<div class="et-order-product-right">
							<bdi><a class="ty-order-products__a litecheckout__order-products-p" href="{"products.view?product_id=`$product.product_id`"|fn_url}"><span class="et-product-title-general">{$product.product nofilter}</span></a></bdi>
							{if !$product.exclude_from_calculate}
								{include file="buttons/button.tpl" but_href="checkout.delete?cart_id=`$key`&redirect_mode=`$runtime.mode`" but_meta="ty-order-products__item-delete delete" but_target_id="cart_status*" but_role="delete" but_name="delete_cart_item"}
							{/if}
              {hook name="products:product_additional_info"}
              {/hook}

							<div class="ty-order-products__price"> 
								<span>{$product.amount}</span><span dir="{$language_direction}">&nbsp;x&nbsp;</span>{include file="common/price.tpl" value=$product.display_price class="ty-price"}
							</div>
							{include file="common/options_info.tpl" product_options=$product.product_options no_block=true}
							{hook name="block_checkout:product_extra"}{/hook}
						</div>
					</li>
				{/if}
			{/hook}
		{/foreach}
	{/hook}
	</ul>
<!--checkout_info_products_{$block.snapping_id}--></div>

As far as I remember, descriptions are not retrieved from the database for the $cart.products or $cart_products arrays. So you should call extra requests do database

Hi!

In case of email notification documents, you will need to extend the default \Tygh\Template\Snippet\Table\ProductVariable class. For this, you will have to create the post schema for this one:
app/schemas/snippets/order_products_table.php

There you will have to specify your own class that will handle the product variable used in the snippet.

The fastest way is to extend the mentioned class, so all you will have to add in your new one is the new public public property of this class, which have to contain value from the $this->product['variation_features']. It will be an array with the list of product features on which this product’s variations are based. For example:

array (
  549 => 
  array (
    'feature_id' => '549',
    'feature_style' => 'dropdown_images',
    'position' => '10',
    'purpose' => 'group_catalog_item',
    'display_on_catalog' => 'Y',
    'description' => 'Color',
    'internal_name' => 'Color',
    'prefix' => '',
    'suffix' => '',
    'purpose_position' => '0',
    'product_feature_purpose' => 'group_catalog_item',
    'variant' => 'Blue',
    'variant_id' => '1199',
    'variant_position' => '2',
  ),
  548 => 
  array (
    'feature_id' => '548',
    'feature_style' => 'dropdown_labels',
    'position' => '20',
    'purpose' => 'group_variation_catalog_item',
    'display_on_catalog' => 'Y',
    'description' => 'Size',
    'internal_name' => 'Size',
    'prefix' => '',
    'suffix' => '',
    'purpose_position' => '1',
    'product_feature_purpose' => 'group_variation_catalog_item',
    'variant' => 'Medium',
    'variant_id' => '1195',
    'variant_position' => '3',
  ),
)

so you will be able to access them using twig’s for operator to iterate through its elements and, for example print the description and variant elements.

Also don’t forget to add the new property to the list of available ones in the attributes method of this class.

You can also check this part of our documentation for some examples:

I hope it will help you.

1 Like

Thanks for the info. But that’s to complicated for me.
I’m not a professional developer. :frowning_face:

Why didn’t you build this “feature” in a update from cs-cart? :roll_eyes:
I think there are many cs-cart users who would need this feature.

1 Like

Hi!

You can contact us via Help Desk so that we may help you in making such a modification.

Anyway… I would like to display a specific product feature field for each product on the shopping cart and checkout page. :neutral_face:

I have already created this field:

  • “warenkorbhinweise” as text field and additional info

How can i display this field in the shopping cart and checkout page?

With the code

{$product.short_description}

I can show the short description field. :+1:
However, this is not available for variants and is also too confusing for customers. :roll_eyes:
Therefore, i need the product feature field mentioned above.

The code

{$product.product.feature.warenkorbhinweise}

or

{foreach from=$product.product_features item="feature" key="feature_name"}
  {if $feature_name == "warenkorbhinweise"}
    <td>{$feature}</td>
  {/if}
{/foreach}

does not work. :confounded: :persevere:
Does anyone have a tip for me?

Hi!

You will have to add gathering of the product features to the $cart_products variable in order to access features data of those products. For example, you can create the POST controller for the checkout with the following content:

<?php

defined('BOOTSTRAP') or die('Access denied');

if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    return;
}
if ($mode === 'checkout' || $mode === 'cart') {
    /** @var \Tygh\SmartyEngine\Core $view */
    $view = Tygh::$app['view'];

    $cart_products = $view->getTemplateVars('cart_products');
    fn_gather_additional_products_data($cart_products, ['get_features' => true]);
    fn_print_r($cart_products['921786304']['product_features']);
    $view->assign('cart_products', $cart_products);
}

This will add product features to the $cart_products variable. The structure of the features will look like thisЖ

Array
(
    [15] => Array
        (
            [feature_id] => 15
            [value] => 
            [value_int] => 
            [variant_id] => 49
            [feature_type] => S
            [internal_name] => Operating System
            [description] => Operating System
            [prefix] => 
            [suffix] => 
            [variant] => Windows 7 Home Basic
            [parent_id] => 14
            [display_on_header] => N
            [display_on_catalog] => Y
            [display_on_product] => Y
            [feature_code] => 
            [purpose] => find_products
            [yml2_exclude_prices] => Array
                (
                    [0] => 
                )

            [yml2_variants_unit] => 
            [yml2_unit] => 
            [features_hash] => 7-49
            [variants] => Array
                (
                    [49] => Array
                        (
                            [value] => 
                            [value_int] => 
                            [variant_id] => 49
                            [variant] => Windows 7 Home Basic
                            [image_pairs] => 
                        )

                )

        )

    [17] => Array
        (
            [feature_id] => 17
            [value] => 
            [value_int] => 
            [variant_id] => 50
            [feature_type] => S
            [internal_name] => Storage Capacity
            [description] => Storage Capacity
            [prefix] => 
            [suffix] => 
            [variant] => 320GB
            [parent_id] => 14
            [display_on_header] => N
            [display_on_catalog] => Y
            [display_on_product] => Y
            [feature_code] => 
            [purpose] => find_products
            [yml2_exclude_prices] => Array
                (
                    [0] => 
                )

            [yml2_variants_unit] => 
            [yml2_unit] => 
            [features_hash] => 9-50
            [variants] => Array
                (
                    [50] => Array
                        (
                            [value] => 
                            [value_int] => 
                            [variant_id] => 50
                            [variant] => 320GB
                            [image_pairs] => 
                        )

                )

        )

)

I hope it will help you.