Skip to content

Commit 5119bdb

Browse files
authored
Merge pull request #11156 from notbakaneko/fix/cart-empty-username
Hotfix adding empty username to cart
2 parents e1c3f5a + 50d53a6 commit 5119bdb

File tree

4 files changed

+5
-3
lines changed

4 files changed

+5
-3
lines changed

app/Models/Store/Order.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -694,7 +694,7 @@ private function newOrderItem(array $params, Product $product)
694694
$params['extra_data'] = ExtraDataSupporterTag::fromOrderItemParams($params, $this->user);
695695
break;
696696
// TODO: look at migrating to extra_data
697-
case 'username-change':
697+
case Product::USERNAME_CHANGE:
698698
// ignore received cost
699699
$params['cost'] = $this->user->usernameChangeCost();
700700
break;

app/Models/Store/OrderItem.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ public function getCustomClassInstance()
115115
{
116116
// only one for now
117117
if ($this->product->custom_class === 'username-change') {
118-
return new ChangeUsername($this->order->user, $this->extra_info);
118+
return new ChangeUsername($this->order->user, $this->extra_info ?? '');
119119
}
120120
}
121121

app/Models/Store/Product.php

+2
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,10 @@
4040
*/
4141
class Product extends Model
4242
{
43+
const BUTTON_DISABLED = [self::SUPPORTER_TAG_NAME, self::USERNAME_CHANGE];
4344
const REDIRECT_PLACEHOLDER = 'redirect';
4445
const SUPPORTER_TAG_NAME = 'supporter-tag';
46+
const USERNAME_CHANGE = 'username-change';
4547

4648
protected $primaryKey = 'product_id';
4749

resources/views/store/products/show.blade.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ class="js-store-item-quantity form-select__input"
128128
<button
129129
class="btn-osu-big btn-osu-big--store-action js-login-required--click js-store-add-to-cart"
130130
type="submit"
131-
{{ $product->custom_class === App\Models\Store\Product::SUPPORTER_TAG_NAME ? 'disabled' : '' }}
131+
{{ in_array($product->custom_class, App\Models\Store\Product::BUTTON_DISABLED, true) ? 'disabled' : '' }}
132132
>
133133
{{ osu_trans('store.product.add_to_cart') }}
134134
</button>

0 commit comments

Comments
 (0)