diff --git a/core/lib/Thelia/Config/Resources/routing/front.xml b/core/lib/Thelia/Config/Resources/routing/front.xml index 38afb7d7f..adbb7d529 100755 --- a/core/lib/Thelia/Config/Resources/routing/front.xml +++ b/core/lib/Thelia/Config/Resources/routing/front.xml @@ -99,7 +99,6 @@ Thelia\Controller\Front\CartController::addItem - cart diff --git a/core/lib/Thelia/Core/EventListener/ViewListener.php b/core/lib/Thelia/Core/EventListener/ViewListener.php index 3bd3147a4..c723c2112 100755 --- a/core/lib/Thelia/Core/EventListener/ViewListener.php +++ b/core/lib/Thelia/Core/EventListener/ViewListener.php @@ -94,7 +94,7 @@ class ViewListener implements EventSubscriberInterface { $request = $this->container->get('request'); - if (!$view = $request->attributes->get('_view')) { + if (null === $view = $request->attributes->get('_view')) { $request->attributes->set('_view', $this->findView($request)); } diff --git a/core/lib/Thelia/Form/CartAdd.php b/core/lib/Thelia/Form/CartAdd.php index 25bde3cdc..fbecd25e1 100755 --- a/core/lib/Thelia/Form/CartAdd.php +++ b/core/lib/Thelia/Form/CartAdd.php @@ -29,6 +29,7 @@ use Thelia\Form\Exception\ProductNotFoundException; use Thelia\Model\ProductSaleElementsQuery; use Thelia\Model\ConfigQuery; use Thelia\Model\ProductQuery; +use Thelia\Core\Translation\Translator; /** * Class CartAdd @@ -75,10 +76,12 @@ class CartAdd extends BaseForm )) ->add("product_sale_elements_id", "text", array( "constraints" => array( + new Constraints\NotBlank(), new Constraints\Callback(array("methods" => array( array($this, "checkStockAvailability") ))) - ) + ), + "required" => true )) ->add("quantity", "text", array( @@ -90,6 +93,10 @@ class CartAdd extends BaseForm new Constraints\GreaterThanOrEqual(array( "value" => 0 )) + ), + "label" => Translator::getInstance()->trans("Quantity"), + "label_attr" => array( + "for" => "quantity" ) )) ->add("append", "hidden") @@ -126,13 +133,17 @@ class CartAdd extends BaseForm { $data = $context->getRoot()->getData(); - $productSaleElements = ProductSaleElementsQuery::create() - ->filterById($data["product_sale_elements_id"]) - ->filterByProductId($data["product"]) - ->findOne(); + if (null === $data["product_sale_elements_id"]) { + $context->addViolationAt("quantity", Translator::getInstance()->trans("Invalid product_sale_elements")); + } else { + $productSaleElements = ProductSaleElementsQuery::create() + ->filterById($data["product_sale_elements_id"]) + ->filterByProductId($data["product"]) + ->findOne(); - if ($productSaleElements->getQuantity() < $value && ConfigQuery::read("verifyStock", 1) == 1) { - $context->addViolation("quantity value is not valid"); + if ($productSaleElements->getQuantity() < $value && ConfigQuery::read("verifyStock", 1) == 1) { + $context->addViolation("quantity value is not valid"); + } } } diff --git a/templates/default/product.html b/templates/default/product.html index 498e81562..7c62eb740 100644 --- a/templates/default/product.html +++ b/templates/default/product.html @@ -93,27 +93,46 @@ preorder : http://schema.org/PreOrder online_only : http://schema.org/OnlineOnly --> - {intl l="Special Price"}: {currency attr="symbol"}26.00 - Regular Price: $36.00 + {if $IS_PROMO } + {loop name="productSaleElements_promo" type="product_sale_elements" product="{$ID}" limit="1"} + {assign var="default_product_sale_elements" value="$ID"} + {intl l="Special Price:"} {format_number number="{$TAXED_PROMO_PRICE}"} {currency attr="symbol"} + {intl l="Regular Price:"} {format_number number="{$TAXED_PRICE}"} {currency attr="symbol"} + {/loop} + {else} + {intl l="Special Price:"} {format_number number="{$BEST_TAXED_PRICE}"} {currency attr="symbol"} + {/if} + {form name="thelia.cart.add" } +
+ {form_hidden_fields form=$form} + + - - - - + {if $form_error}
{$form_error_message}
{/if} + {form_field form=$form field='product_sale_elements_id'} + {if $default_product_sale_elements } + + {else} + {loop name="productSaleElements_promo" type="product_sale_elements" product="{$ID}" limit="1"} + + {/loop} + {/if} + {/form_field} + {form_field form=$form field="product"} + + {/form_field}
@@ -122,38 +141,50 @@
Size
- $value) { ?> -
-
- - + {form_field form=$form field='quantity'} +
+ + + {if $error } + {$message} + {elseif $value != "" && !$error} + + {/if}
+ {/form_field}
- +
+ {/form}
-
-

Raw denim you probably haven't heard of them jean shorts Austin. Nesciunt tofu stumptown aliqua, retro synth master cleanse. Mustache cliche tempor, williamsburg carles vegan helvetica. Reprehenderit butcher retro keffiyeh dreamcatcher synth. Cosby sweater eu banh mi, qui irure terry richardson ex squid. Aliquip placeat salvia cillum iphone. Seitan aliquip quis cardigan american apparel, butcher voluptate nisi qui.

+
+

{$DESCRIPTION}

-
+

Food truck fixie locavore, accusamus mcsweeney's marfa nulla single-origin coffee squid. Exercitation +1 labore velit, blog sartorial PBR leggings next level wes anderson artisan four loko farm-to-table craft beer twee. Qui photo booth letterpress, commodo enim craft beer mlkshk aliquip jean shorts ullamco ad vinyl cillum PBR. Homo nostrud organic, assumenda labore aesthetic magna delectus mollit. Keytar helvetica VHS salvia yr, vero magna velit sapiente labore stumptown. Vegan fanny pack odio cillum wes anderson 8-bit, sustainable jean shorts beard ut DIY ethical culpa terry richardson biodiesel. Art party scenester stumptown, tumblr butcher vero sint qui sapiente accusamus tattooed echo park.