Combining custom fields with product options

  • Posts: 47
  • Thank you received: 0
13 years 7 months ago #13914

Hi Nicolas (and community members),

I'm building a webshop for flowers, optionally the customer can order a card or a ribbon to go with the flowers.
When a user selects a card or ribbon, they must be able to enter the text for the card or ribbon in an extra field.

I've looked at the business version demo, and found the entries functionality that displays some dropdowns only when others are selected.
I'm thinking we could use the flowers as entries, and let the customer select if they want a card or ribbon with it, and then upon selecting on of these display a text area where they can enter their desired text.
The question with this solution is, can we send the custom text to the order confirmation?

However, that is not a really neat solution since we want to preferably display the cards and ribbons as "Featured products". Although we might try to use that if there's no better solution.

If done the regular way, maybe it is possible to show the custom fields on the registration page only when a certain product is in the cart, or do you have any other suggestions about how i can accomplish this?
Maybe we can use the "additional information" field (as seen in the demo) at the end of the checkout process to display only when a card or ribbon is in the cart? This way the registration form would also be cleaner, and less complicated when dealing with existing customers.


We also have another question; is there a possibility to show custom fields ONLY on the shipping address form but not on the regular customer address form?

We are thinking of upgrading to the business version, but of course we would like know if it will/can meet our requirements.

Kind regards,
Woes

Last edit: 13 years 7 months ago by woes.

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

  • Posts: 82867
  • Thank you received: 13374
  • MODERATOR
13 years 7 months ago #13918

Hi,

There is no option to display the custom fields of the table order only when certain products are in the cart. However, that's something which can be added without too much trouble by changing a bit the code of the view. You can go in the menu Display->Views and edit the file fields of the view checkout. There, change the line:
if(hikashop::level(2) && !empty($this->extraFields)){
for:
$display = false;
foreach($this->rows as $i => $row){
if(in_array($row->product_code,array('product_which_need_fields_1','product_which_need_fields_2'))){ $display=true;}
}
if($display && hikashop::level(2) && !empty($this->extraFields)){

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

  • Posts: 47
  • Thank you received: 0
13 years 7 months ago #13920

Hi Nicolas,

Thanks for your quick reply, i've tried to find the checkout view, but cannot find your suggested line to be replaced, i've also tried to "grep" trough them but without result.

In the meantime i found some information about the tables "order" and "item" available in the business version.
It seems these will be of great help to our project.
So i'm guessing also this checkout view is available in the business version only, since i noticed you say "custom fields of the table order".

About my other question, is there a possibility to show custom fields ONLY on the shipping address form but not on the regular customer address form?

We need this because we need a lot of extra custom fields for the shipping address (for delivery at events), and this will usually differ from the customer address.

Thanks again!

Kind regards,
Woes

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

  • Posts: 82867
  • Thank you received: 13374
  • MODERATOR
13 years 7 months ago #13930

Yes, that view is only in the Business edition, that's why you didn't find it.

It could be possible to hide some fields in the billing address, but that will require that you modify a bit the code of both the address_view file of the view checkout and the form file of the view address. In the first one, you will have to add in the edit URL the variable $this->type so that on the second view, you can know whether you're displaying a shipping or a billing address.

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

  • Posts: 47
  • Thank you received: 0
13 years 6 months ago #15614

Hi Nicolas,

So far the business edition works out great, now i've come to the point of actually implementing the changes as stated here, the issue with the table "order" works flawless, but i can not seem to get the specific shipping address fields to work only there..

I'm not sure where to add $this->type, and also not sure how to display the specific address fields only on the shipping address in the form file of the view address..

Any help would be greatly appreciated.

Kind regards,
Woes

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

  • Posts: 82867
  • Thank you received: 13374
  • MODERATOR
13 years 6 months ago #15623

Hi,

In several (two) place of the address_view file, you have the code:
echo hikashop::completeLink('address&redirect=checkout&....
which displays the link of the popup of creation/edition of an address.
There, you need to add a parameter with the $this->type variable. For example:
echo hikashop::completeLink('address&redirect=checkout&address_type='.$this->type.'&....

Then, in the address form, after the line:
foreach($this->extraFields as $fieldName => $oneExtraField) {

you can do something like that for example :
if(fieldName=="address_state" && JRequest::getVar('address_type')=='billing'){
continue; //skip the address_state field for the billing address
}

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

  • Posts: 47
  • Thank you received: 0
13 years 6 months ago #15673

I've implemented the changes and the fields still display on the register form.. i've added my changes below:

Added the following fields:
Table - column name - Label
address naamoverledene Naam (overledene)
address address_overledene Naam2 (overledene)


Changes in address / form.php


foreach($this->extraFields as $fieldName => $oneExtraField) {
if(fieldName=="address_overledene" && JRequest::getVar('address_type')=='billing'){
continue; //skip the address_state field for the billing address
if(fieldName=="naamoverledene" && JRequest::getVar('address_type')=='billing'){
continue; //skip the address_state field for the billing address
if(fieldName=="address_naamoverledene" && JRequest::getVar('address_type')=='billing'){
continue; //skip the address_state field for the billing address
}
?>
<tr>


Changes in checkout - adddress_view (bottom code, changes highlighted in bold text)

<span class="hikashop_checkout_<?php echo $this->type;?>_address_buttons">
<a title="<?php echo JText::_('HIKA_DELETE'); ?>" class="hikashop_checkout_<?php echo $this->type;?>_address_delete" href="<?php echo hikashop::completeLink('checkout&step='.$this->step.'&redirect=checkout&task=deleteaddress&address_id='.$address->address_id.'&'.JUtility::getToken().'=1');?>"><img alt="<?php echo JText::_('HIKA_DELETE'); ?>" src="<?php echo HIKASHOP_IMAGES; ?>delete.png" border="0" /></a>
<a title="<?php echo JText::_('HIKA_EDIT'); ?>" class="modal hikashop_checkout_<?php echo $this->type;?>_address_edit" rel="{handler: 'iframe', size: {x: 450, y: 480}}" href="<?php echo hikashop::completeLink('address&task=edit&address_type='.$this->type.'&redirect=checkout&address_id='.$address->address_id.'&step='.$this->step,true);?>" onclick="SqueezeBox.fromElement(this,{parse: 'rel'});return false;"><img alt="<?php echo JText::_('HIKA_EDIT'); ?>" src="<?php echo HIKASHOP_IMAGES; ?>edit.png" border="0" /></a>
</span>
</td>
</tr>
<?php
}
?>
</table>
<?php
}
?>
<span id="hikashop_checkout_<?php echo $this->type;?>_address_new" class="hikashop_checkout_<?php echo $this->type;?>_address_new">
<a id="hikashop_checkout_<?php echo $this->type;?>_address_new_link" rel="{handler: 'iframe', size: {x: 450, y: 480}}" href="<?php echo hikashop::completeLink('address&redirect=checkout&address_type='.$this->type.'&task=add&step='.$this->step,true);?>" onclick="SqueezeBox.fromElement(this,{parse: 'rel'});return false;">
<?php echo $this->cart->displayButton(JText::_('HIKA_NEW'),'new',$this->params,'','var link = document.getElementById(\'hikashop_checkout_'. $this->type.'_address_new_link\'); if(link) SqueezeBox.fromElement(link,{parse: \'rel\'});return false;'); ?>
</a>
</span>

Last edit: 13 years 6 months ago by woes.

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

  • Posts: 82867
  • Thank you received: 13374
  • MODERATOR
13 years 6 months ago #15745

Ah, it's for the registration view ? These changes where for the address edition popup.
For the registration view, you can just add the code:
if(fieldName=="address_naamoverledene") continue;

after the line:
foreach($this->extraFields[$type] as $fieldName => $oneExtraField) {

in the file custom_fields of the view user.

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

  • Posts: 47
  • Thank you received: 0
13 years 6 months ago #15779

Hi Nicolas,

Thanks for your reply, I've changed the below code to user / custom/fields.php, but the field still displays on the register form.


<?php
$type = $this->type;
foreach($this->extraFields[$type] as $fieldName => $oneExtraField) {
if(fieldName=="address_naamoverledene") {
continue;
}
?>
<tr

Also i got an error on the edition popup with the previous changes (unexpected $end), tried to add a } to end the IF, and the error is gone, but it still displays the custom field on the popup..

<?php
foreach($this->extraFields as $fieldName => $oneExtraField) {

if(fieldName=="address_naamoverledene" && JRequest::getVar('address_type')=='billing'){
continue; //skip the address_state field for the billing address
}
?>


I really wonder what i'm doing wrong here..

Last edit: 13 years 6 months ago by woes.

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

  • Posts: 82867
  • Thank you received: 13374
  • MODERATOR
13 years 6 months ago #15794

I suppose that you means user / custom_fields.php, right ?
Are you sure that the column name of your field is address_naamoverledene and not naamoverledene ? Because I've seen both in your code snippets...

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

  • Posts: 47
  • Thank you received: 0
13 years 6 months ago #15805

Yes, i made a typo there, i have tried to add both, the column name is indeed just "naamoverledene", i have tried to do it like:

foreach($this->extraFields[$type] as $fieldName => $oneExtraField) {
if(fieldName=="address_naamoverledene") {
continue;
}
if(fieldName=="naamoverledene") {
continue;
}
?>


and also like:

foreach($this->extraFields[$type] as $fieldName => $oneExtraField) {
if(fieldName=="address_naamoverledene") continue;
if(fieldName=="naamoverledene") continue;
?>

but with both, the field still displays..

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

  • Posts: 82867
  • Thank you received: 13374
  • MODERATOR
13 years 6 months ago #15815

So either you're not doing the modification in the good template (if you have several templates you need to do the view modification in the template which is used on the checkout), or the column names are not good.

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

  • Posts: 47
  • Thank you received: 0
13 years 6 months ago #15816

I've tried about everything, i'm only using one template, i've also tried the changes on checkout / custom_fields.php just to be sure.

I will mail you my joomla admin login so you can check if anything is wrong, perhaps i'm really overlooking something..

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

  • Posts: 82867
  • Thank you received: 13374
  • MODERATOR
13 years 6 months ago #15819

It should be $fieldName and not fieldName as I wrote earlier.

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

  • Posts: 47
  • Thank you received: 0
13 years 6 months ago #15995

Great, such a minor detail can be so important, the fields are now hidden on the register form!

Unfortunately, after registering a new account and clicking the activiation link, the address turns out not to be saved, (both billing and shipping address are empty) then when i add a shipping address, it adds as a billing address.. (probably because none exist yet, also tried to check via the backend if user data is perhaps saved there, but it's all blank).

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

  • Posts: 82867
  • Thank you received: 13374
  • MODERATOR
13 years 6 months ago #15997

That's a known issue for people who downloaded hikashop 1.4.9 just after the release. You can fix it by following that post: www.hikashop.com/en/support/forum/4-how-...to-paypal.html#14348

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

Time to create page: 0.090 seconds
Powered by Kunena Forum