Search code examples
modxmodx-revolutionmodx-chunks

How to pass product TVs to SimpleCart's scGetCart snippet?


I need some TVs (weight, dimensions, etc) I've associated with my products to appear in the Cart page of my SimpleCart site.

Problem is I have no idea how to do this. I don't understand how the SimpleCart cart is built and there isn't documentation for this.

Would anyone know how I can show TVs associated with each product in the cart output chunk?

The cart snippet has the following code which gets data from the cart and puts it into Chunks:

$sc = $modx->getService('simplecart','SimpleCart',$modx->getOption('simplecart.core_path',null,$modx->getOption('core_path').'components/simplecart/').'model/simplecart/',$scriptProperties);
if (!($sc instanceof SimpleCart)) return '';
 
$controller = $sc->loadController('Cart');
$output = $controller->run($scriptProperties);

The output Chunk looks like:

<div id="simplecart">

    <form action="[[~[[*id]]]]" method="post" id="form_cartoverview">
        <input type="hidden" name="updatecart" value="true" />

        <table>
          <tr>
            <th class="desc">[[%simplecart.cart.description]]</th>
            <th class="price">[[%simplecart.cart.price]]</th>
            <th class="quantity">[[%simplecart.cart.quantity]]</th>
            [[+cart.total.vat_total:notempty=`<th class="quantity">[[%simplecart.cart.vat]]</th>`:isempty=``]]
            <th class="subtotal">[[%simplecart.cart.subtotal]]</th>
            <th> </th>
          </tr>

            [[+cart.wrapper]]

          [[+cart.total.discount:notempty=`<tr class="total first discount">
            <td colspan="[[+cart.total.vat_total:notempty=`3`:isempty=`2`]]"> </td>
            <td class="label">[[%simplecart.cart.discount]]</td>
            <td class="value">- [[+cart.total.discount_formatted]]</td>
            <td class="extra">[[+cart.total.discount_percent:notempty=`([[+cart.total.discount_percent]]%)`:isempty=` `]]</td>
          </tr>`:isempty=``]]

        [[+cart.total.vat_total:notempty=`
          <tr class="total [[+cart.total.discount:notempty=`second`:isempty=`first`]]">
            <td colspan="3"> </td>
            <td class="label">[[%simplecart.cart.total_ex_vat]]</td>
            <td class="value">[[+cart.total.price_ex_vat_formatted]]</td>
            <td class="extra"> </td>
          </tr>
          [[+cart.vat_rates]]
          <tr class="total [[+cart.total.discount:notempty=`third`:isempty=`second`]]">
            <td colspan="3"> </td>
            <td class="label">[[%simplecart.cart.total_vat]]</td>
            <td class="value">[[+cart.total.vat_total_formatted]]</td>
            <td class="extra"> </td>
          </tr>
          <tr class="total [[+cart.total.discount:notempty=`fourth`:isempty=`third`]]">
            <td colspan="3"> </td>
            <td class="label">[[%simplecart.cart.total_in_vat]]</td>
            <td class="value">[[+cart.total.price_formatted]]</td>
            <td class="extra"> </td>
          </tr>
        `:isempty=`
          <tr class="total [[+cart.total.discount:notempty=`second`:isempty=`first`]]">
            <td colspan="2"> </td>
            <td class="label">[[%simplecart.cart.total]]</td>
            <td class="value">[[+cart.total.price_formatted]]</td>
            <td class="extra"> </td>
          </tr>
        `]]
        </table>

        <div class="submit">
            <input type="submit" value="[[%simplecart.cart.update]]" />
        </div>
    </form>

Solution

  • Found (through trial and error) you must use:

    [[+product.tv.name_of_tv]]