checkout subpart(signature)

Help for integrating the Laravel package
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!
hyalcin
Posts: 11
Joined: 09 Aug 2024, 13:22

checkout subpart(signature)

Post by hyalcin » 26 Aug 2024, 11:38

I want to create a subpart for signature after the address subpart in the checkout process. And all the files required for the subpart I created, such as m_order_signatur table and Manager Dekorator etc. I also want to show my signature in the summary. Can you inform me on how to manage this process?

Code: Select all

<?php

/**
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
 * @copyright Metaways Infosystems GmbH, 2013
 * @copyright Aimeos (aimeos.org), 2015-2024
 */

$enc = $this->encoder();
$sig = $this->get('signature', []);
$prefix = $this->get('prefix', '');
$disabled = $this->get('disabled', true);
$fnames = $this->get('formnames', []);
$error = $this->get('error', []);
$css = $this->get('css', []);


use Illuminate\Support\Facades\Session;
?>
<?php $this->block()->start('checkout/standard/signature') ?>
<div class="section checkout-standard-signature">

	<h1><?= $enc->html($this->translate('client', 'signature'), $enc::TRUST) ?></h1>
	<p class="note">
		<?= $enc->html($this->translate('client', 'Fields with an * are mandatory'), $enc::TRUST) ?>
	</p>

	<div class="form-item form-group signature <?= $enc->attr(($this->value($error, 'signature') ? 'error ' : '') . join(' ', $this->value($css, 'signature', []))) ?>">
		<img id="signature-img" src="" alt="Signature" style="display: none; max-width: 100%; height: auto;" />
		<div class="col-md-12">

			<div class="col-md-9 ">
				<div class="card">

					<div class="card-body">
						<?php if ($message = Session::get('success')): ?>
							<div class="alert alert-success alert-dismissible">
								<button type="button" class="close" data-dismiss="alert">×</button>
								<strong><?= $enc->html($message, $enc::TRUST) ?></strong>
							</div>
						<?php endif; ?>
						<div class="signature-text">
							<label for="sig">
								<?= $enc->html($this->translate('client', 'signature'), $enc::TRUST) ?>
							</label>
						</div>
						<div class="col-md-12">

							<div id="sig" class="signature" width=400 height=200></div>

							<textarea id="address-signature" name="signature" style="display: none"></textarea>

						</div>

						<button id="address-signature-clear" class="btn btn-danger btn-sm">Clear Signature</button>
						<button type="button" id="address-signature-save-signature" class="btn btn-success mt-2">Save</button>

					</div>
				</div>
			</div>

		</div>
	</div>

	<div class="button-group">
		<a class="btn btn-default btn-lg btn-back" href="<?= $enc->attr($this->get('standardUrlBack')) ?>">
			<?= $enc->html($this->translate('client', 'Previous'), $enc::TRUST) ?>
		</a>
		<button type="submit" id="btnOrder" class="btn btn-primary btn-lg btn-action">
			<?= $enc->html($this->translate('client', 'Next'), $enc::TRUST) ?>
		</button>
	</div>

</div>
<?php $this->block()->stop() ?>
<?= $this->block()->get('checkout/standard/signature') ?>
My signature-body/php file, which I created by copying one of the other checkout/standard files.

setup/default/shema/order.php

Code: Select all

<?php

return [
    'table' => [
        'mshop_order_address' => function (\Aimeos\Upscheme\Schema\Table $table) {

            $table->string('care_fund');
            $table->string('insurance_number');
            $table->integer('care_level');
        },
        'mshop_order_signature' => function (\Aimeos\Upscheme\Schema\Table $table) {
            $table->engine = 'InnoDB';

            $table->id()->primary('pk_msordsig_id');
            $table->bigint('user_id')->null(true);
            $table->bigint('order_id')->null(true);
            $table->string('path');
            $table->addColumn('created_at', 'datetime', ['notnull' => false]);
            $table->addColumn('updated_at', 'datetime', ['notnull' => false]);
            $table->foreign('user_id', 'users', 'id', 'fk_msordsig_id');
            $table->foreign('order_id', 'mshop_order', 'id', 'fk_msord_id');
        }

    ],
];
src/MShop/Order/Manager/Signature/Standard.php

Code: Select all

<?php

namespace Aimeos\MShop\Order\Manager\Signature;

class Standard
extends \Aimeos\MShop\Common\Manager\Base
implements \Aimeos\MShop\Common\Manager\Iface
{
    public function getSaveAttributes(): array
    {
        return $this->createAttributes([
            'user_id' => [
                'type' => 'int',
                'public' => false,
                'label' => 'User ID'
            ],
            'order_id' => [
                'type' => 'int',
                'public' => false,
                'label' => 'Order ID'
            ],
            'path' => [
                'type' => 'string',
                'label' => 'Path to the signature image file'
            ],
            'created_at' => [
                'type' => 'datetime',
                'public' => false,
                'label' => 'Creation date and time'
            ],
            'updated_at' => [
                'type' => 'datetime',
                'public' => false,
                'label' => 'Last update date and time'
            ],
        ]);
    }

    protected function getTable(): string
    {
        return 'mshop_order_signature';
    }
}

User avatar
aimeos
Administrator
Posts: 8148
Joined: 01 Jan 1970, 00:00

Re: checkout subpart(signature)

Post by aimeos » 27 Aug 2024, 20:01

You need a subpart for the Checkout/Standard HTML client too which uses your template to display the values and handles the data sent by the form POST:
https://aimeos.org/docs/latest/frontend ... kout-steps
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply