Skip to content

Commit

Permalink
Prevent checkouts with disabled products (#1308)
Browse files Browse the repository at this point in the history
  • Loading branch information
BelleNottelling committed Jun 12, 2023
1 parent 28559c3 commit 56a64fe
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/modules/Cart/Service.php
Expand Up @@ -500,6 +500,11 @@ public function createFromCart(\Model_Client $client, $gateway_id = null)
foreach ($this->getCartProducts($cart) as $p) {
$item = $this->cartProductToApiArray($p);

$product = $this->di['db']->getExistingModelById('Product', $item['product_id']);
if (is_null($product) || $product->status !== 'enabled') {
throw new \Box_Exception("Unable to complete order. One or more of the selected products are invalid.");
}

/*
* Convert the domain name to lowercase letters.
* Using a capital letter in a domain name still points to the same name, so this isn't going to break anything
Expand All @@ -514,7 +519,7 @@ public function createFromCart(\Model_Client $client, $gateway_id = null)
$item['domain']['transfer_sld'] = (isset($item['domain']['transfer_sld'])) ? strtolower($item['domain']['transfer_sld']) : null;

// Domain TLD must begin with a period - add if not present for owndomain.
$item['domain']['owndomain_tld'] = (isset( $item['domain']['owndomain_tld'])) ? (str_contains($item['domain']['owndomain_tld'], '.') ? $item['domain']['owndomain_tld'] : '.' . $item['domain']['owndomain_tld']) : null;
$item['domain']['owndomain_tld'] = (isset($item['domain']['owndomain_tld'])) ? (str_contains($item['domain']['owndomain_tld'], '.') ? $item['domain']['owndomain_tld'] : '.' . $item['domain']['owndomain_tld']) : null;

$order = $this->di['db']->dispense('ClientOrder');
$order->client_id = $client->id;
Expand Down

0 comments on commit 56a64fe

Please sign in to comment.