Magento 2 create order programmatically

Here we are discussing how to create order programmatically in magetno Code for creating a quote Continuing to declare the order in the module helper file by the following function:

To add a custom tab to user roles

Step 1 : We need to create an acl.xml in the etc folder of <vendorname><module name>.write the following code in the acl.xml file. step 2:  Check whether the vendor name is the same as in the menu.xml file. step 3:  Flush Magento cache.

Published
Categorized as Magento

How to covert file to base64

in custom javascript: function setInputValue(element) { var file = element.files[0]; var reader = new FileReader(); reader.onloadend = function() { console.log(‘RESULT’, reader.result) console.log(this.result); buttonbase64=this.result; }reader.readAsDataURL(file);} var base = buttonbase64; in phtml file : <input id=”upload” type=”file” onchange=”encodePdfFileAsURL(this)” name=”uploadbutton” accept=”.pdf”>

Published
Categorized as Magento

Get Invoice details by order id programmatically Magento 2

You can get the invoice data for the specific order by order id in Magento 2. Using Magento\Sales\Api\InvoiceRepositoryInterface interface, you need to use getList() function to fetch no. of invoice by sales order id. Using SearchCriteriaBuilder Class, You need to filter by order id and pass search criteria object to getList() method of InvoiceRepositoryInterface. <?php namespace Path\To\Class; use Exception; use Psr\Log\LoggerInterface; use Magento\Sales\Api\Data\InvoiceInterface;… Continue reading Get Invoice details by order id programmatically Magento 2

Published
Categorized as Magento

Method to Get Order Information By Order Id in Magento 2

With the below solution, you can get the order details like order items, order amount, location of the order delivery, order payment method, billing details, quantity, and the customer name.   $orderId = 123;  $objectManager = \Magento\Framework\App\ObjectManager::getInstance();  $order = $objectManager->create(‘\Magento\Sales\Model\OrderRepository’)->get($orderId);  // Get Order Information   $order->getEntityId();  $order->getIncrementId();  $order->getState();  $order->getStatus();  $order->getStoreId();  $order->getGrandTotal();  $order->getSubtotal();  $order->getTotalQtyOrdered();  $order->getOrderCurrencyCode();   //… Continue reading Method to Get Order Information By Order Id in Magento 2

Published
Categorized as Magento

How to disable source code, control u,v, and inspect sections using jQuery?

inspect disable $(document).bind(“contextmenu”,function(e) {e.preventDefault(); }); disable f12$(document).keydown(function (event) {if (event.keyCode == 123) { // Prevent F12return false;} else if (event.ctrlKey && event.shiftKey && event.keyCode == 73) { // Prevent Ctrl+Shift+Ireturn false;}}); disable ctl+u jQuery(document).ready(function($){$(document).keydown(function(event) {var pressedKey = String.fromCharCode(event.keyCode).toLowerCase(); if (event.ctrlKey && (pressedKey == “c” || pressedKey == “u”)) {// alert(‘Sorry, This Functionality Has Been Disabled!’);//disable… Continue reading How to disable source code, control u,v, and inspect sections using jQuery?

Published
Categorized as Magento

Add a new attribute in eav_attribute

Here I need to add a new attribute ‘dealer_name’. So in an existing dealer module added a new folder controller and created a file installData.php we need to delete this(dealer) module in php myadmin and do the following php bin/magento setup:upgrade php bin/magento setup:di:compile php bin/magento setup:static-content:deploy -f sudo chmod 777 -R /var/www/html/Corp-design/ Then we… Continue reading Add a new attribute in eav_attribute

Published
Categorized as Magento

NetSuite gets API trigger twice when called a CURLOPT_URL

Sometimes when we are posting some values to Netsuite through their API, the API is triggered twice because we may posting the params to the response as the same response from NetSuite. Avoid printing the params in the response. Try this instead of :

How to decode the response and get the data from response.

$response = curl_exec($curl); $jsonArray = json_decode($response, true); if($jsonArray[‘status’] == 200) { $responseArray=$jsonArray[‘response’]; $freight_option=$responseArray[‘freight_option’]; $freight_minimum_amount=$responseArray[‘freight_minimum_amount’]; }

Published
Categorized as Magento