Jump to content

Format Customized Data In Blockcart-Json


hanny137

Recommended Posts

I store a bunch of values from a form in a customized field.

 

I have adjusted it to display appropriately in blockcart.tpl and other places in my template.  But when I first add it to the cart and it is passed to blockcart-JSON - it displays the truncated version which I do not want.

 

Here is how I make it look nice elsewhere (blockcart.tpl):

{if isset($customization.datas.$CUSTOMIZE_TEXTFIELD.0)}
{$encoded_values = $customization.datas.$CUSTOMIZE_TEXTFIELD.0.value}
{$decoded_url_values = urldecode($encoded_values)}
{$json_values = json_decode($decoded_url_values)}
{$json_key_values=array_keys($json_values)}

{foreach $json_values as $orderItems }

    <div class='cart-item-customization'>
        <h6>{l s='Item '}{$orderItems@index+1}</h6>
        <ul>
    {foreach $orderItems as $orderItem }
        <li>{l s='Line '}{$orderItem@index+1} : {$orderItem->engraving}</li>
    {/foreach}
        </ul>
    </div>

{/foreach}

How would I do something similar in blockcart-json?

 

Here is where the customized data is at in blockcart-json:

{foreach from=$datas key='index' item='data' name='datas'}
    {ldelim}
	"index": {$index|intval},
	"value": {Tools::nl2br($data.value)|json_encode},
	"truncatedValue": {Tools::nl2br($data.value|truncate:28:'...')|json_encode}
	{rdelim}{if !$smarty.foreach.datas.last},{/if}
{/foreach}]

What can I do to make it display appropriately?

Edited by hanny137 (see edit history)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...