issues in Implementing Delivery Provider
Forum rules
Always add your Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Always add your Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Re: issues in Implementing Delivery Provider
Hey guys waiting for reply
Re: issues in Implementing Delivery Provider
hey guys please have a look at this problem
Re: issues in Implementing Delivery Provider
Your code looks correct.khizar wrote: ↑07 Apr 2021, 11:39Code: Select all
if($t->data[0]->success){ // here is the code for saving attributes $status = \Aimeos\MShop\Order\Item\Base::STAT_PROGRESS; $order->setDeliveryStatus( $status ); // $this->saveOrder( $order ); $attributes = ['reference_number' => $t->data[0]->reference_number]; $serviceType = \Aimeos\MShop\Order\Item\Base\Service\Base::TYPE_DELIVERY; $orderServiceItem = $order->getService( $serviceType ); $this->setAttributes( $orderServiceItem, $attributes, 'myprovider' ); $this->saveOrderBase( $basket ); } return $order; } }
In the order list view it's more difficult because the order details are not loaded there:khizar wrote: ↑07 Apr 2021, 11:39 Now if above code is right can you please tell me how can i access that reference no in orders listplease note that the above foreach loop is from the orders list and it contains code but for the sake of simplicity i picked up only start and end of the loop can you please tell me here how can i access that reference numberCode: Select all
<?php foreach( $this->get( 'items', [] ) as $id => $item ) : ?> <?php endforeach; ?>
https://github.com/aimeos/ai-client-htm ... d.php#L218
You would have to overwrite that method with your own version in your own extension and use:
Code: Select all
$view->listsOrderItems = $cntl->uses( ['order/base', 'order/base/service'] )->sort( '-order.id' )->search();
Code: Select all
if( $service = current( $item->getBaseItem()->getService( 'delivery' ) ) ) {
$ref = $service->getAttribute( 'reference_number', 'myprovider' );
}
Note: We answer questions in the forum in our spare time.
If you need immediate response, please ask the Aimeos company for paid support:
https://aimeos.com/support
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: issues in Implementing Delivery Provider
I have completed my task .I want to you to have a look at my code and guide me is it correct or not so that i can move on to next task .i am getting my desired result but not sure my approach is right or not so please guide me.i am posting my code belowaimeos wrote: ↑09 Apr 2021, 07:08Your code looks correct.khizar wrote: ↑07 Apr 2021, 11:39Code: Select all
if($t->data[0]->success){ // here is the code for saving attributes $status = \Aimeos\MShop\Order\Item\Base::STAT_PROGRESS; $order->setDeliveryStatus( $status ); // $this->saveOrder( $order ); $attributes = ['reference_number' => $t->data[0]->reference_number]; $serviceType = \Aimeos\MShop\Order\Item\Base\Service\Base::TYPE_DELIVERY; $orderServiceItem = $order->getService( $serviceType ); $this->setAttributes( $orderServiceItem, $attributes, 'myprovider' ); $this->saveOrderBase( $basket ); } return $order; } }
In the order list view it's more difficult because the order details are not loaded there:khizar wrote: ↑07 Apr 2021, 11:39 Now if above code is right can you please tell me how can i access that reference no in orders listplease note that the above foreach loop is from the orders list and it contains code but for the sake of simplicity i picked up only start and end of the loop can you please tell me here how can i access that reference numberCode: Select all
<?php foreach( $this->get( 'items', [] ) as $id => $item ) : ?> <?php endforeach; ?>
https://github.com/aimeos/ai-client-htm ... d.php#L218
You would have to overwrite that method with your own version in your own extension and use:Then, you can get the reference in the loop using:Code: Select all
$view->listsOrderItems = $cntl->uses( ['order/base', 'order/base/service'] )->sort( '-order.id' )->search();
https://github.com/aimeos/aimeos-core/b ... e.php#L151Code: Select all
if( $service = current( $item->getBaseItem()->getService( 'delivery' ) ) ) { $ref = $service->getAttribute( 'reference_number', 'myprovider' ); }
Note: We answer questions in the forum in our spare time.
If you need immediate response, please ask the Aimeos company for paid support:
https://aimeos.com/support
Code: Select all
<?php
namespace Aimeos\MShop\Service\Provider\Delivery;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Log;
class Myprovider
extends \Aimeos\MShop\Service\Provider\Delivery\Base
implements \Aimeos\MShop\Service\Provider\Delivery\Iface
{
/**
* Sends the order details to the ERP system for further processing.
*
* @param \Aimeos\MShop\Order\Item\Iface $order Order invoice object to process
*/
public function process(\Aimeos\MShop\Order\Item\Iface $order): \Aimeos\MShop\Order\Item\Iface
{
$parts = \Aimeos\MShop\Order\Item\Base\Base::PARTS_ALL;
$basket = $this->getOrderBase($order->getBaseId(), $parts);
$data = []; // note that it contains data but i have skipped that part
$apiurl = 'http://demodashboardapi.shipsy.in/api/customer/integration/consignment/softdata';
$response = Http::withHeaders([
"api-key" => "XXXXXXXXXXXXXX",
"Content-Type" => "application/json"
])->post($apiurl,$data);
$t = json_decode($response);
if($t->data[0]->success){
info('entered into success method');
$attributes = ['reference_number' => $t->data[0]->reference_number,'message'=>''];
$serviceType = \Aimeos\MShop\Order\Item\Base\Service\Base::TYPE_DELIVERY;
$orderServiceItem = $basket->getService( $serviceType );
if(($serviceItem = reset($orderServiceItem)) !== false){
$status = \Aimeos\MShop\Order\Item\Base::STAT_PROGRESS;
$order->setDeliveryStatus( $status );
// $this->saveOrder( $order );
$this->setAttributes( $serviceItem, $attributes, 'myprovider' );
$this->saveOrderBase( $basket );
}
}else{
$attributes = ['reference_number' => '', 'message' => $t->data[0]->message];
$serviceType = \Aimeos\MShop\Order\Item\Base\Service\Base::TYPE_DELIVERY;
$orderServiceItem = $basket->getService( $serviceType );
if(($serviceItem = reset($orderServiceItem)) !== false){
$this->setAttributes( $serviceItem, $attributes, 'myprovider' );
$this->saveOrderBase( $basket );
}
}
return $order;
}
}
Code: Select all
<?php
$baseItems = $this->get( 'baseItems', [] );
foreach( $this->get( 'items', [] ) as $id => $item ) :
$baseItem = ( isset( $baseItems[$item->getBaseId()] ) ? $baseItems[$item->getBaseId()] : null );
$reference_no = '';
$message = '';
$serviceType = \Aimeos\MShop\Order\Item\Base\Service\Base::TYPE_DELIVERY;
$orderServiceItem = $baseItem->getService( $serviceType );
if(($serviceItem = reset($orderServiceItem)) !== false){
$reference_no = $serviceItem->getAttribute( 'reference_number', 'myprovider' );
// $attrItem = $serviceItem->getAttributeItem( 'reference_number', 'myprovider' );
$message = $serviceItem->getAttribute( 'message', 'myprovider' );
}
endforeach:
?>
Re: issues in Implementing Delivery Provider
In principle, it should be correct.
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