Answers.Body: <p>To inject the button into the order edit page, you can use the <a href="https://craftcms.com/docs/commerce/5.x/extend/template-hooks.html#orders" rel="nofollow noreferrer"><code>cp.commerce.order.edit.order-actions</code></a> <a href="https://craftcms.com/docs/5.x/extend/template-hooks.html" rel="nofollow noreferrer">template hook</a> via a custom plugin/module.</p>
  <pre class="lang-php prettyprint-override"><code>use Craft;
  
  Craft::$app-&gt;getView()-&gt;hook('cp.commerce.order.edit.order-actions',
      function() {
          $url = UrlHelper::actionUrl('module/order/send-cart-link');
          return '&lt;a href=&quot;' . $url . '&quot; class=&quot;btn&quot;&gt;Send Cart Link&lt;/a&gt;';
      }
  );
  </code></pre>
  <p>What remains is to create your own <code>module/order/send-cart-link</code> controller action that does the actual sending of the cart link, but that feels like it is beyond the scope of this answer.</p>
  <p>Good luck!</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-06-28T08:00:28.910Z
Answers.LastActivityDate: 2024-06-28T08:00:28.910Z
Answers.UserDisplayName: Ben Croker
Body: <p>I'm looking for the best way to add a 'Send Cart Link' button to the Order entry view in Commerce 4/Craft 4.</p>
  <p>Currently the 'Share Cart' link is behind the cog in the top right of the order view. This then opens a popup with the URL to the cart.</p>
  <p>What I would like to do is add a new button to the top right of the order view that would take the customer email and trigger an email to be sent to the customer with the cart URL.</p>
  <p>On the site that this would be for, the company often make bespoke carts/orders for clients and would like a more streamlined way of sending these to the client rather than clicking the button, copying and pasting the link and sending it manually via an email.</p>
  <p>This also opens up the possibility of using a nice branded HTML template to send the cart link to the customer.</p>
  
Tags: <plugin-craftcommerce><craft4><commerce4><cart>
Title: How to add a 'Share Cart' button to send email to customer with cart link
ThreadText: # How to add a 'Share Cart' button to send email to customer with cart link
  
  (Asked by: username_0 on 2024-06-27)
  
  I'm looking for the best way to add a 'Send Cart Link' button to the Order entry view in Commerce 4/Craft 4.
  
  Currently the 'Share Cart' link is behind the cog in the top right of the order view. This then opens a popup with the URL to the cart.
  
  What I would like to do is add a new button to the top right of the order view that would take the customer email and trigger an email to be sent to the customer with the cart URL.
  
  On the site that this would be for, the company often make bespoke carts/orders for clients and would like a more streamlined way of sending these to the client rather than clicking the button, copying and pasting the link and sending it manually via an email.
  
  This also opens up the possibility of using a nice branded HTML template to send the cart link to the customer.
  
  **Tags:** plugin-craftcommerce, craft4, commerce4, cart
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2024-06-28. Score: 2 | Accepted answer
  
  To inject the button into the order edit page, you can use the [`cp.commerce.order.edit.order-actions`](https://craftcms.com/docs/commerce/5.x/extend/template-hooks.html#orders) [template hook](https://craftcms.com/docs/5.x/extend/template-hooks.html) via a custom plugin/module.
  
  ```php
  use Craft;
  
  Craft::$app->getView()->hook('cp.commerce.order.edit.order-actions',
      function() {
          $url = UrlHelper::actionUrl('module/order/send-cart-link');
          return '<a href="' . $url . '" class="btn">Send Cart Link</a>';
      }
  );
  
  ```
  
  What remains is to create your own `module/order/send-cart-link` controller action that does the actual sending of the cart link, but that feels like it is beyond the scope of this answer.
  
  Good luck!
  
  
  ---
  
  