Coder Social home page Coder Social logo

Comments (5)

moinmalek17 avatar moinmalek17 commented on July 22, 2024

Hi,

Please try below links where I passed the delivery date in API.

Edit the events.xml file on global state SR/DeliveryDate/etc/events.xml

<?xml version="1.0" encoding="UTF-8"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd"> <event name="sales_model_service_quote_submit_before"> <observer name="sr_delivery_date" instance="SR\DeliveryDate\Observer\SaveDeliveryDateToOrderObserver"/> </event> <event name="sales_order_load_after"> <observer name="sales_order_load_order_attribute" instance="SR\DeliveryDate\Observer\Sales\OrderLoadAfter" /> </event> </config>

Then edit the SR/DeliveryDate/etc/extension_attributes.xml

<?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Api/etc/extension_attributes.xsd"> <extension_attributes for="Magento\Checkout\Api\Data\ShippingInformationInterface"> <attribute code="delivery_date" type="string"/> <attribute code="delivery_comment" type="string"/> </extension_attributes> <extension_attributes for="Magento\Sales\Api\Data\OrderInterface"> <attribute code="delivery_date" type="string" /> </extension_attributes> </config>

And After that create a observer file SR\DeliveryDate\Observer\Sales\OrderLoadAfter.php to get the delivery date.

<?php namespace SR\DeliveryDate\Observer\Sales; use Magento\Framework\Event\ObserverInterface; class OrderLoadAfter implements ObserverInterface { public function execute(\Magento\Framework\Event\Observer $observer) { $order = $observer->getOrder(); $extensionAttributes = $order->getExtensionAttributes(); if ($extensionAttributes === null) { $extensionAttributes = $this->getOrderExtensionDependency(); } $attr = $order->getData('delivery_date'); $extensionAttributes->setDeliveryDate($attr); $order->setExtensionAttributes($extensionAttributes); } private function getOrderExtensionDependency() { $orderExtension = \Magento\Framework\App\ObjectManager::getInstance()->get( '\Magento\Sales\Api\Data\OrderExtension' ); return $orderExtension; } }

from magento2-module-delivery-date.

moinmalek17 avatar moinmalek17 commented on July 22, 2024

Hi @anas-shehadeh

You can check the my repo on github https://github.com/moinmalek17/magento2-module-delivery-date-with-api

Thanks

from magento2-module-delivery-date.

malafalx91 avatar malafalx91 commented on July 22, 2024

have API been added?

from magento2-module-delivery-date.

moinmalek17 avatar moinmalek17 commented on July 22, 2024

Hi @malafalx91 ,

Please check below link for that https://github.com/moinmalek17/magento2-module-delivery-date-with-api.

Thanks

from magento2-module-delivery-date.

malafalx91 avatar malafalx91 commented on July 22, 2024

@moinmalek17 I installed your module, I tried to do this GET:
http: // mysite / rest / V1 / orders / 2
but I don't find any reference to the delivery field.
Can you tell me what GET I have to do?

from magento2-module-delivery-date.

Related Issues (19)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.