Change 'Shipping' to 'Delivery' in Simple Cart Order Summary

3 posts by 2 authors in: Forums > CMS Builder
Last Post: September 7   (RSS)

Where is 'name' set in the code below?

Can it be easily changed without screwing-up anything else? Thanks!

<?php if ($extraLineItems): ?>
<?php foreach ($extraLineItems as $extraLineField => $extraLineItem): ?>
<div class="row">
<div class="col-6">
<p class="mb-0"><?php echo htmlencode($extraLineItem['name']); ?></p>
</div>
<div class="col-6">
<p class="text-end mb-0"><?php echo sc_moneyFormat($extraLineItem['TOTAL']); ?></p>
</div>
</div>
<?php endforeach; ?>
<?php endif; ?>
Jeff

Hi Jeff, 

It looks like $extraLineItems is an array of fieldnames to arrays.  So name is defined in $extraLineItems.

I'm not familiar with that exact piece of code but if you want to override output for a single value you can do it like this

<p class="mb-0">
<?php 
if ($extraLineItem['name'] === 'previous value') { 
  echo "new value"; 
}
else { 
 echo htmlencode($extraLineItem['name']);
}
?>
</p>

Or you can use the new match expression in PHP 8.0+ which can be simpler than long if/if else/else statements:

<p class="mb-0">
<?php
echo match ($extraLineItem['name']) {
    'old value 1'   => 'new value 1',
    'another value' => 'new value 2',
    default         => htmlencode($extraLineItem['name']),
};
?>
</p>

Hope that helps!

Dave Edis - Senior Developer
interactivetools.com