0

I'm using CartThrob for e-commerce. I need to display a block of content only if the package displayed contains a product with a certain entry_id. I was assuming I could just wrap the block of content in a conditional that checks the included products for an entry_id? The channel entry_id of the product I need to check for is 23.

If possible, I could also use a tip on how to enable shipping only for packages that contain this product with this entry_id.

Here is my main template:

{exp:channel:entries channel="rides" limit="1" dynamic="no" url_title="{segment_3}"}
            <main role="main" class="inner-page view">
        <p class="read-more"><a href="/pro-rides" class="blue">&laquo; Back to Pro Rides</a></p>
                    <article>
            <h2>{title}</h2>
            <img src="{ride_img}" alt="{title}, ${ride_price}" />
            <p class="lead">Price: ${ride_price}</p>
            {if ride_body}
            <p>{ride_body}</p>
            {if:else}
            <p>{ride_excerpt}</p>
            {/if}
        </article>
        <section>
            {embed="views/.packages"}
        </section>
{/exp:channel:entries}

Here is the embedded packages template:

{exp:channel:entries channel="store_packages" dynamic="no"}
{if related_ride == "{segment_3}"}
    <ul>
            <li>{title}, {entry_id}: {packages_price} </li>
            {!-- check for product entry_id inclusion --}
            <li><!-- content displayed conditionally --></li>
            {!-- end conditional --}
            <li><p class="read-more"><a href="{entry_id_path=checkout/cart}" class="blue">Purchase Ride now &raquo;</a></p></li>
    </ul>
{/if}
{/exp:channel:entries}
0

I ended up finally figuring out how to access the custom cartThrob Package fields (I couldn't find any documentation in the cartThrob docs for this) and used the following:

{exp:channel:entries channel="store_packages" dynamic="no"}
{if related_ride == "{segment_3}"}
    <ul>
            <li>{title}, {entry_id}: {packages_price} </li>
            {packages}{if "{sub:entry_id}" == "23"}Bring your own Bike{if:elseif "{sub:entry_id}" == "24"}Rent our Bike{/if}{/packages}
            <li><p class="read-more"><a href="{entry_id_path=checkout/cart}" class="blue">Purchase Ride now &raquo;</a></p></li>
    </ul>
{/if}
{/exp:channel:entries}

Now off to figure out how to add shipping only to packages that contain this product entry_id!

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.