1

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.

1 Answer 1

2

To inject the button into the order edit page, you can use the cp.commerce.order.edit.order-actions template hook via a custom plugin/module.

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!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.