How to transform a quote into an order from CALLBACK HOOKS, MAGENTO 2.3

I’m trying to integrate a payment gateway. And they provide a callback hooks i’ve set for them to return me the CartID (Quote’s entity_id).

But from here on, it feels like it isnt right for me to call guest API, as the cart belongs to an actual customer’s cart. Neither do i have the access tokens when the callback hook is being sent to the API i’ve created.

How can i create the order (sales_order table & sales_order_grid) based on the quote i could receive ?

Please advise what should i do as im stuck on this for 3 days.

Magento 2 : Add product to cart programmatically does not populate quote item id in validate method

How to add product to cart programmatically in Magento 2.2.0 ?

I have tried below code but when I do not get Quote item id in Validate method of below file.

\Magento\AdvancedSalesRule\Model\Rule\Condition\Product.php 

Code:

protected $  formKey;    protected $  cart; protected $  product;  public function __construct( \Magento\Framework\App\Action\Context $  context, \Magento\Framework\Data\Form\FormKey $  formKey, \Magento\Checkout\Model\Cart $  cart, \Magento\Catalog\Model\Product $  product, array $  data = []) {     $  this->formKey = $  formKey;     $  this->cart = $  cart;     $  this->product = $  product;           parent::__construct($  context); }  public function execute()  {    $  productId = 32;   $  params = array(                 'form_key' => $  this->formKey->getFormKey(),                 'product' => $  productId,                  'qty'   => 2                             );                    $  _product = $  this->product->load($  productId);        $  this->cart->addProduct($  _product, $  params);      $  this->cart->save();  } 

Sales Rule Validate Method Code:

File: \Magento\AdvancedSalesRule\Model\Rule\Condition\Product.php

Method:

public function validate(\Magento\Framework\Model\AbstractModel $  model)     {         //@todo reimplement this method when is fixed MAGETWO-5713         /** @var \Magento\Catalog\Model\Product $  product */         $  product = $  model->getProduct();         if (!$  product instanceof \Magento\Catalog\Model\Product) {             $  product = $  this->productRepository->getById($  model->getProductId());         }          if ($  model instanceof \Magento\Quote\Model\Quote\Item) {             die($  model->getItemId()); //NULL 

Thanks

Magento 2.3 Convert Quote from store to another store

I need to convert a quote from one store in GBP to another website store in EUR dynamically on the fly, but i can save the item with the new store_Id and the quote with the correct store_id but collectTotals is not recalculating to get the store level prices.

       $  quote = $  this->quoteRepository->getActive($  cartId);          $  quote->setStore($  store);          $  items =  $  this->quoteRepository->getActive($  cartId)->getAllItems();         foreach($  items as $  item)         {             $  item = $  quote->getItemById($  item->getId());             $  item->setData('store_id',$  storeId);             $  item->calcRowTotal();             $  item->getProduct()->setIsSuperMode(true);             $  item->save();         }          $  quote->setTotalsCollectedFlag(false)->collectTotals()->save(); 

Any advice? Or any ideas would be appreciated.

Forcing search engine to display stock quote in Chrome

Is there a way (extension, tag) to input a stock ticker into the Google Chrome search bar and return the relevant yahoo finance/ google finance/bloomberg page for a stock?

Most of the time google is very good about showing a finance card but there are numerous tickers (KORS) comes to mind where the finance card doesn’t show up at all.

Add same product to quote as a separate item in Magento 2

I want to add the same product to quote but separately. Here is my code [php]

    $  quote = $  this->quote->create();     $  quote->setStore($  store);     $  quote->setCurrency();   $  skuArray = array('EC1','EC1);  foreach($  skuArray as $  sku){  $  item = null; $  item = $  this->productRepository->get(sku); $  addedItem = $  quote->addProduct($  item, 1);  if ($  customer->getId()) {         $  quote->assignCustomer($  customer);     }  $  quote->collectTotals(); $  quote->save();       } 

Every time Magento is adding one item in the quote_item table with two qty in quote table. But I want two items added separately in the quote_item table.

I know if we can add a custom option to each item Magento will treat it as a separate item so i have created observer to add a custom option to cart in ‘sales_quote_product_add_after’ event

class AddAfterProduct implements ObserverInterface { public function execute(Observer $  observer) {     $  items = $  observer->getItems();      foreach ($  items as $  item) {          $  additionalOptions = array(              array(                'code' => 'custom_option',                'label' => 'Custom Option',                'value' => rand(0,1111)            )         );         $  item->addOption(             array(                 'code' => 'additional_options',                 'value' =>  serialize($  additionalOptions),             )         );     } } } 

This is also not working. Can somebody help me with this problem?

getFileByServerRelativeURL fails when the filename contains a quote

I’m using the SharePoint online REST API. Things generally work fine, but I’m failing to figure out how to get information about a file (document) that contains a quote in its name. Here’s my REST call:

https://mysite.sharepoint.com/_api/Web/getfilebyserverrelativeurl("/Shared Documents/Roy's quoted doc.txt") 

The response I’m getting is ‘400 Bad Request’, with the error being “The expression “Web/getfilebyserverrelativeurl(“/Shared Documents/Roy’s quoted doc.txt”)” is not valid.”

I’ve tried all sorts of tricks with encoding the path (%27 encoding for the quote sign, backslashing the quote, etc.), but failed to figure out the right one.

Is there any kind of encoding I’m not aware of?

Quote Item level manual Discount – Magento 2

I need to give Quote Item level manual Discount for selected cart items. After giving discount Cart Item row total will change. As can’t modify the product price so custom price solution is also not working.

I tried with new discount total but it gives discount on whole cart.

Anyone please suggest best approach for giving discount on Cart item level without modify product price.

Thanks

single quote and double quotes in sed

I tested the single quote and double quotes in sed

me@host:~: $   echo "front" | sed "s/front/back/" back me@host:~: $   echo "front" | sed 's/front/back/' back 

They performed identically, but I remembered to read there exist differences between them months ago.

Google search not helpful with keywords “single quotes and double quotes in sed”.

They are not identically, right?