Display custom field in user profile and mail
Forum rules
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Display custom field in user profile and mail
Hi,
I added a custom field to customer's address using a Address\Decorator:
The field is displayed in the customers profile (backend) and also stored in DB.
How can I display the field value eg. on the checkout confirm page or in the payment mail?
tried with $addr->get( 'custid' ); but without success:
thank you.
I added a custom field to customer's address using a Address\Decorator:
Code: Select all
namespace Aimeos\MShop\Customer\Manager\Address\Decorator;
class Myproject extends \Aimeos\MShop\Common\Manager\Decorator\Base
{
private $attr = [
'custid' => [
'code' => 'custid',
'internalcode' => 'lvuad."custid"',
'label' => 'Kundennummer',
'type' => 'string',
'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR,
],
];
public function getSaveAttributes() : array
{
return parent::getSaveAttributes() + $this->createAttributes( $this->attr );
}
public function getSearchAttributes( bool $sub = true ) : array
{
return parent::getSearchAttributes( $sub ) + $this->createAttributes( $this->attr );
}
}
How can I display the field value eg. on the checkout confirm page or in the payment mail?
tried with $addr->get( 'custid' ); but without success:
Code: Select all
<?php foreach( $this->summaryBasket->getAddress( 'custid' ) as $addr ) : ?>
<?= $addr->getCompany();?>
<?= $addr->getPostal();?>
<?= $addr->getCity();?><br>
<?= $addr->get( 'custid' ); ?>
<?php endforeach; ?>
Re: Display custom field in user profile and mail
This doesn't return anything:
You have to use:
Code: Select all
$this->summaryBasket->getAddress( 'custid' )
Code: Select all
$this->summaryBasket->getAddress( 'delivery' )
// or
$this->summaryBasket->getAddress( 'payment' )
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star
Re: Display custom field in user profile and mail
sorry, copy/paste mistake, I already have: $this->summaryBasket->getAddress( 'delivery' )
how can I print out the value of the custom field custid?
does not return any value
how can I print out the value of the custom field custid?
Code: Select all
<?php foreach( $this->summaryBasket->getAddress( 'delivery' ) as $addr ) : ?>
<?= $addr->get( 'custid' ); ?>
<?php endforeach; ?>
Re: Display custom field in user profile and mail
Should be working. You can use print_r() to display the content of the address item object.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star
Re: Display custom field in user profile and mail
Custid is stored in DB table "users_address" successfully, but not part of the address item object displayed with:
Do I have an error in my decorator?
Code: Select all
<?= print_r( $this->summaryBasket->getAddress( 'delivery' ) ) ; ?>
Code: Select all
<?php
namespace Aimeos\MShop\Customer\Manager\Address\Decorator;
// add custid-field to each customer address
class Myproject extends \Aimeos\MShop\Common\Manager\Decorator\Base
{
private $attr = [
'custid' => [
'code' => 'custid',
'internalcode' => 'lvuad."custid"',
'label' => 'CustId Address',
'type' => 'string',
'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR,
],
];
public function getSaveAttributes() : array
{
return parent::getSaveAttributes() + $this->createAttributes( $this->attr );
}
public function getSearchAttributes( bool $sub = true ) : array
{
return parent::getSearchAttributes( $sub ) + $this->createAttributes( $this->attr );
}
}
Re: Display custom field in user profile and mail
Implementation looks fine and your decorator is used. Otherwise, the values won't be stored.
Did you change the SQL for "search" in user_address? What's the current SQL statement?
You can check if you configure:
Did you change the SQL for "search" in user_address? What's the current SQL statement?
You can check if you configure:
Code: Select all
madmin/log/manager/loglevel = 7
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star
Re: Display custom field in user profile and mail
yes, custid is part of the select query.
and I got it to appear on checkout\standard page address-delivery-body-standard.php
but Unfortunately still not on the checkout\confirm page order-body-standard.php
Code: Select all
SELECT lvuad."custid",
lvuad."id" AS "customer.address.id", lvuad."parentid" AS "customer.address.parentid",
lvuad."company" AS "customer.address.company", lvuad."vatid" AS "customer.address.vatid",
lvuad."salutation" AS "customer.address.salutation", lvuad."title" AS "customer.address.title",
lvuad."firstname" AS "customer.address.firstname", lvuad."lastname" AS "customer.address.lastname",
lvuad."address1" AS "customer.address.address1", lvuad."address2" AS "customer.address.address2",
lvuad."address3" AS "customer.address.address3", lvuad."postal" AS "customer.address.postal",
lvuad."city" AS "customer.address.city", lvuad."state" AS "customer.address.state",
lvuad."countryid" AS "customer.address.countryid", lvuad."langid" AS "customer.address.languageid",
lvuad."telephone" AS "customer.address.telephone", lvuad."email" AS "customer.address.email",
lvuad."telefax" AS "customer.address.telefax", lvuad."website" AS "customer.address.website",
lvuad."longitude" AS "customer.address.longitude", lvuad."latitude" AS "customer.address.latitude",
lvuad."pos" AS "customer.address.position", lvuad."mtime" AS "customer.address.mtime",
lvuad."editor" AS "customer.address.editor", lvuad."ctime" AS "customer.address.ctime",
lvuad."siteid" AS "customer.address.siteid", lvuad."birthday" AS "customer.address.birthday"
FROM "users_address" AS lvuad
WHERE ( ( lvuad."siteid" = '' OR lvuad."siteid" = '1.' ) AND lvuad."parentid" IN ('3') )
ORDER BY lvuad."pos" ASC
OFFSET 0 ROWS FETCH NEXT 2147483647 ROWS ONLY
and I got it to appear on checkout\standard page address-delivery-body-standard.php
Code: Select all
<?php foreach( $this->get( 'addressDeliveryValues', '' ) as $addr ) : ?>
Lastname: <?= $addr['order.base.address.lastname']; ?>
Custid: <?= $addr['custid']; ?>
<?php endforeach; ?>
Code: Select all
<?php foreach( $this->summaryBasket->getAddress( 'delivery' ) as $addr ) : ?>
Lastname: <?= $addr->get( 'order.base.address.lastname' ); ?><br>
Custid: : <?= $addr->get( 'custid' ); ?> <br>
<?php endforeach; ?>
Re: Display custom field in user profile and mail
You need another decorator for the order/base/address manager to tell it how the custid should be stored/retrieved just like you've did for the customer/address manager.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star