Populate Custom Field Value in Manual Shipping Inf

  • Posts: 103
  • Thank you received: 0
12 years 1 month ago #72007

Hi There,

For the charity we run a campaign and the products are delivered to the campaigning organization on a certain date. Is there a way to populate this organization name (taken from the custom field on an earlier step) into the

Hand delivered Free shipping

Choose this method and your order will be delivered to your chosen Organization

Easy? Possible?

Thanks!
Susan

Attachments:

Please Log in or Create an account to join the conversation.

  • Posts: 13201
  • Thank you received: 2322
12 years 1 month ago #72064

Hi,

Yes it's possible, for your shipping method description click on the toggle editor and replace the text by:

Choose this method and your order will be delivered to your chosen <div id="chsnOrg">Organization</div> ...

Then in HikaShop > Display > Views, edit the view "checkout / custom_fields" and replace the exiting code by:
<?php
	$type = $this->type;
	foreach($this->extraFields[$type] as $fieldName => $oneExtraField) {
	?>
		<tr class="hikashop_checkout_<?php echo $fieldName;?>_line" id="hikashop_<?php echo $type.'_'.$oneExtraField->field_namekey; ?>">
			<td class="key">
				<?php echo $this->fieldsClass->getFieldName($oneExtraField);?>
			</td>
			<td>
				<?php $onWhat='onchange'; if($oneExtraField->field_type=='radio') $onWhat='onclick';
					echo $this->fieldsClass->display($oneExtraField,$this->$type->$fieldName,'data['.$type.']['.$fieldName.']',false,' '.$onWhat.'="document.getElementById(\'chsnOrg\').innerHTML = this.value; hikashopToggleFields(this.value,\''.$fieldName.'\',\''.$type.'\',0);"');
				?>
			</td>
		</tr>
	<?php }	?>

If you have many custom fields in the checkout, an "if" condition will be necessary to do the action only if the custom field is the good one.

Please Log in or Create an account to join the conversation.

  • Posts: 103
  • Thank you received: 0
12 years 1 month ago #72286

Hi Xavier,

Thanks. Do I need to set the custom field to be chsnOrg somewhere? I have made these changes.. and it's blank

" Pick Up Free shipping

Choose this method and your order will be delivered to
on the arranged Campaign Date .."

Please Log in or Create an account to join the conversation.

  • Posts: 82868
  • Thank you received: 13376
  • MODERATOR
12 years 4 weeks ago #72480

Hi,

Xavier didn't understand what you wanted to do.

You want to add in the shipping description to value of a custom field which has been selected previously.


That's possible with a small view modification but we would need a screenshot of the options of your custom field in order to tell you what to do exactly.

Please Log in or Create an account to join the conversation.

  • Posts: 103
  • Thank you received: 0
12 years 4 weeks ago #72504

Hi There,

Thanks.. I did what Xavier suggested using the column name "organizername", no luck.

Attached is my custom field screenshot. THANKS!

Suz

Attachments:

Please Log in or Create an account to join the conversation.

  • Posts: 82868
  • Thank you received: 13376
  • MODERATOR
12 years 4 weeks ago #72776

Hi,

You can edit the file "shipping" of the view "checkout" via the menu Display->Views and change the code:
<div class="hikashop_checkout_shipping_description"><?php echo $rate->shipping_description;?></div>

to:
<?php
$app = JFactory::getApplication();
$order = $app->getUserState( HIKASHOP_COMPONENT.'.checkout_fields',null); ?>
<div class="hikashop_checkout_shipping_description"><?php echo str_replace('{organizer}',@$order->organizername,$rate->shipping_description);?></div>

Then, you can use the tag {organizer} in your shipping methods description and it will be replaced by the selected value of that custom field.

Please Log in or Create an account to join the conversation.

Time to create page: 0.137 seconds
Powered by Kunena Forum