コード例 #1
0
 /**
  * @param \Symfony\Component\HttpFoundation\Request $request
  *
  * @return \Symfony\Component\HttpFoundation\JsonResponse
  */
 public function editAction(Request $request)
 {
     $form = $this->getFactory()->createCustomerForm($request);
     if ($form->isValid() === true) {
         $customerTransfer = new CustomerTransfer();
         $customerTransfer->fromArray($form->getRequestData());
         $this->getFacade()->updateCustomer($customerTransfer);
     }
     return $this->jsonResponse($form->renderData());
 }
コード例 #2
0
ファイル: Customer.php プロジェクト: spryker/Wishlist
 /**
  * @return \Generated\Shared\Transfer\WishlistTransfer
  */
 public function getWishlist()
 {
     $wishlist = $this->wishlistQueryContainer->queryWishlist()->findOneByFkCustomer($this->customerTransfer->getIdCustomer());
     $wishlistTransfer = new WishlistTransfer();
     foreach ($wishlist->getSpyWishlistItems() as $wishlistItemEntity) {
         $wishlistItemTransfer = new ItemTransfer();
         $productEntity = $wishlistItemEntity->getSpyProduct();
         $wishlistItemTransfer->setGroupKey($wishlistItemEntity->getGroupKey())->setAddedAt($wishlistItemEntity->getAddedAt())->setIdProductAbstract($wishlistItemEntity->getFkProductAbstract())->setSku($productEntity->getSku())->setQuantity($wishlistItemEntity->getQuantity());
         $wishlistTransfer->addItem($wishlistItemTransfer);
     }
     return $wishlistTransfer;
 }
コード例 #3
0
ファイル: AddController.php プロジェクト: spryker/Customer
 /**
  * @param \Symfony\Component\HttpFoundation\Request $request
  *
  * @return array|\Symfony\Component\HttpFoundation\RedirectResponse
  */
 public function indexAction(Request $request)
 {
     $dataProvider = $this->getFactory()->createCustomerFormDataProvider();
     $form = $this->getFactory()->createCustomerForm($dataProvider->getData(), $dataProvider->getOptions())->handleRequest($request);
     if ($form->isValid()) {
         $customerTransfer = new CustomerTransfer();
         $customerTransfer->fromArray($form->getData(), true);
         $this->getFacade()->registerCustomer($customerTransfer);
         return $this->redirectResponse('/customer');
     }
     return $this->viewResponse(['form' => $form->createView()]);
 }
コード例 #4
0
 /**
  * @return void
  */
 public function testAddPaymentToQuoteShouldReturnQuoteTransfer()
 {
     $paymentHandler = new PayolutionHandler($this->getPayolutionClientMock(), CurrencyManager::getInstance());
     $request = Request::createFromGlobals();
     $quoteTransfer = new QuoteTransfer();
     $billingAddress = new AddressTransfer();
     $billingAddress->setSalutation('Mr');
     $billingAddress->setIso2Code('iso2Code');
     $quoteTransfer->setBillingAddress($billingAddress);
     $customerTransfer = new CustomerTransfer();
     $customerTransfer->setEmail('*****@*****.**');
     $quoteTransfer->setCustomer($customerTransfer);
     $paymentTransfer = new PaymentTransfer();
     $paymentTransfer->setPaymentSelection('payolutionInvoice');
     $payolutionPaymentTransfer = new PayolutionPaymentTransfer();
     $paymentTransfer->setPayolutionInvoice($payolutionPaymentTransfer);
     $quoteTransfer->setPayment($paymentTransfer);
     $result = $paymentHandler->addPaymentToQuote($request, $quoteTransfer);
     $this->assertInstanceOf(QuoteTransfer::class, $result);
 }
コード例 #5
0
ファイル: EditController.php プロジェクト: spryker/Customer
 /**
  * @param \Symfony\Component\HttpFoundation\Request $request
  *
  * @return array|\Symfony\Component\HttpFoundation\RedirectResponse
  */
 public function indexAction(Request $request)
 {
     $idCustomer = $this->castId($request->query->get(CustomerConstants::PARAM_ID_CUSTOMER));
     $dataProvider = $this->getFactory()->createCustomerUpdateFormDataProvider();
     $form = $this->getFactory()->createCustomerUpdateForm($dataProvider->getData($idCustomer), $dataProvider->getOptions($idCustomer))->handleRequest($request);
     if ($form->isValid()) {
         $customerTransfer = new CustomerTransfer();
         $customerTransfer->fromArray($form->getData(), true);
         $this->getFacade()->updateCustomer($customerTransfer);
         $defaultBilling = $customerTransfer->getBillingAddress() ?: null;
         if (!$defaultBilling) {
             $this->updateBillingAddress($idCustomer, $defaultBilling);
         }
         $defaultShipping = $customerTransfer->getShippingAddress() ?: null;
         if (!$defaultShipping) {
             $this->updateShippingAddress($idCustomer, $defaultShipping);
         }
         return $this->redirectResponse(sprintf('/customer/view/?%s=%d', CustomerConstants::PARAM_ID_CUSTOMER, $idCustomer));
     }
     return $this->viewResponse(['form' => $form->createView(), 'idCustomer' => $idCustomer]);
 }
コード例 #6
0
ファイル: Propel.php プロジェクト: spryker/Wishlist
 /**
  * @param \Generated\Shared\Transfer\WishlistChangeTransfer $wishlistChange
  *
  * @return \Generated\Shared\Transfer\WishlistTransfer
  */
 public function removeItems(WishlistChangeTransfer $wishlistChange)
 {
     $idCustomer = $this->customerTransfer->getIdCustomer();
     $wishlistEntity = $this->getWishlistEntity($idCustomer);
     $wishlistItems = $wishlistChange->getItems();
     foreach ($wishlistItems as $wishlistItemTransfer) {
         $wishlistItemEntity = $this->getWishlistItemEntity($wishlistItemTransfer, $wishlistEntity->getIdWishlist());
         if (empty($wishlistItemEntity)) {
             continue;
         }
         $quantityDifference = $wishlistItemEntity->getQuantity() - $wishlistItemTransfer->getQuantity();
         if ($quantityDifference <= 0) {
             $this->deleteWishlistItem($wishlistItemEntity);
         } else {
             $wishlistItemEntity->setQuantity($quantityDifference);
             $wishlistItemEntity->save();
         }
     }
     $wishlistTransfer = $this->customer->getWishlist();
     return $wishlistTransfer;
 }
コード例 #7
0
 /**
  * @return \Generated\Shared\Transfer\QuoteTransfer
  */
 private function getValidBaseQuoteTransfer()
 {
     $country = new SpyCountry();
     $country->setIso2Code('ix');
     $country->save();
     $quoteTransfer = new QuoteTransfer();
     $billingAddress = new AddressTransfer();
     $billingAddress->setIso2Code('ix')->setAddress1('address-1-1-test')->setFirstName('Max')->setLastName('Mustermann')->setZipCode('1337')->setCity('SpryHome');
     $shippingAddress = new AddressTransfer();
     $shippingAddress->setIso2Code('ix')->setAddress1('address-1-2-test')->setFirstName('Max')->setLastName('Mustermann')->setZipCode('1337')->setCity('SpryHome');
     $totals = new TotalsTransfer();
     $totals->setGrandTotal(1337)->setSubtotal(337);
     $quoteTransfer->setShippingAddress($shippingAddress)->setBillingAddress($billingAddress)->setTotals($totals);
     $customerTransfer = new CustomerTransfer();
     $customerTransfer->setEmail('*****@*****.**');
     $customerTransfer->setFirstName('Max');
     $customerTransfer->setLastName('Mustermann');
     $quoteTransfer->setCustomer($customerTransfer);
     $shipmentTransfer = new ShipmentTransfer();
     $shipmentTransfer->setMethod(new ShipmentMethodTransfer());
     $quoteTransfer->setShipment($shipmentTransfer);
     $itemTransfer = new ItemTransfer();
     $itemTransfer->setUnitGrossPrice(1)->setQuantity(1)->setName('test-name')->setSku('sku-test');
     $quoteTransfer->addItem($itemTransfer);
     $paymentTransfer = new PaymentTransfer();
     $paymentTransfer->setPaymentSelection('dummyPaymentInvoice');
     $quoteTransfer->setPayment($paymentTransfer);
     return $quoteTransfer;
 }
コード例 #8
0
ファイル: Customer.php プロジェクト: spryker/Customer
 /**
  * @param \Generated\Shared\Transfer\CustomerTransfer $customerTransfer
  *
  * @return \Generated\Shared\Transfer\CustomerTransfer
  */
 protected function encryptNewPassword(CustomerTransfer $customerTransfer)
 {
     $currentPassword = $customerTransfer->getNewPassword();
     $customerTransfer->setNewPassword($this->getEncodedPassword($currentPassword));
     return $customerTransfer;
 }
コード例 #9
0
 /**
  * @return \Generated\Shared\Transfer\QuoteTransfer
  */
 protected function getBaseQuoteTransfer()
 {
     $quoteTransfer = new QuoteTransfer();
     $country = new SpyCountry();
     $country->setIso2Code('xi')->save();
     $productAbstract1 = new SpyProductAbstract();
     $productAbstract1->setSku('AOSB1337')->setAttributes('{}');
     $productConcrete1 = new SpyProduct();
     $productConcrete1->setSku('OSB1337')->setAttributes('{}')->setSpyProductAbstract($productAbstract1)->save();
     $productAbstract2 = new SpyProductAbstract();
     $productAbstract2->setSku('AOSB1338')->setAttributes('{}');
     $productConcrete2 = new SpyProduct();
     $productConcrete2->setSku('OSB1338')->setSpyProductAbstract($productAbstract2)->setAttributes('{}')->save();
     $stock = new SpyStock();
     $stock->setName('testStock');
     $stock1 = new SpyStockProduct();
     $stock1->setQuantity(1)->setStock($stock)->setSpyProduct($productConcrete1)->save();
     $stock2 = new SpyStockProduct();
     $stock2->setQuantity(1)->setStock($stock)->setSpyProduct($productConcrete2)->save();
     $item1 = new ItemTransfer();
     $item1->setSku('OSB1337')->setQuantity(1)->setUnitGrossPrice(3000)->setName('Product1');
     $item2 = new ItemTransfer();
     $item2->setSku('OSB1338')->setQuantity(1)->setUnitGrossPrice(4000)->setName('Product2');
     $quoteTransfer->addItem($item1);
     $quoteTransfer->addItem($item2);
     $totals = new TotalsTransfer();
     $totals->setGrandTotal(1000)->setSubtotal(500);
     $quoteTransfer->setTotals($totals);
     $billingAddress = new AddressTransfer();
     $shippingAddress = new AddressTransfer();
     $billingAddress->setIso2Code('xi')->setEmail('*****@*****.**')->setFirstName('Max')->setLastName('Mustermann')->setAddress1('Straße')->setAddress2('82')->setZipCode('12345')->setCity('Entenhausen');
     $shippingAddress->setIso2Code('xi')->setFirstName('Max')->setLastName('Mustermann')->setEmail('*****@*****.**')->setAddress1('Straße')->setAddress2('84')->setZipCode('12346')->setCity('Entenhausen2');
     $quoteTransfer->setBillingAddress($billingAddress);
     $quoteTransfer->setShippingAddress($shippingAddress);
     $customerTransfer = new CustomerTransfer();
     $customerTransfer->setIsGuest(false)->setEmail('*****@*****.**');
     $quoteTransfer->setCustomer($customerTransfer);
     $shipment = new ShipmentTransfer();
     $shipment->setMethod(new ShipmentMethodTransfer());
     $quoteTransfer->setShipment($shipment);
     $paymentTransfer = new PaymentTransfer();
     $paymentTransfer->setPaymentSelection('no_payment');
     $quoteTransfer->setPayment($paymentTransfer);
     return $quoteTransfer;
 }
コード例 #10
0
 /**
  * @param \Generated\Shared\Transfer\CustomerTransfer $customerTransfer
  *
  * @return bool
  */
 protected function isNewCustomer(CustomerTransfer $customerTransfer)
 {
     return $customerTransfer->getIdCustomer() === null;
 }
コード例 #11
0
 /**
  * @return void
  */
 public function testRestorePasswordNonExistent()
 {
     $customerTransfer = new CustomerTransfer();
     $customerTransfer->setEmail(self::TESTER_NON_EXISTING_EMAIL);
     $customerResponseTransfer = $this->customerFacade->sendPasswordRestoreMail($customerTransfer);
     $this->assertTrue($customerResponseTransfer->getIsSuccess());
 }
コード例 #12
0
ファイル: SaverTest.php プロジェクト: spryker/Payolution
 /**
  * @param \Generated\Shared\Transfer\CheckoutResponseTransfer $checkoutResponseTransfer
  *
  * @return \Generated\Shared\Transfer\QuoteTransfer
  */
 private function getQuoteTransfer(CheckoutResponseTransfer $checkoutResponseTransfer)
 {
     $orderEntity = $this->createOrderEntity();
     $paymentAddressTransfer = new AddressTransfer();
     $email = '*****@*****.**';
     $paymentAddressTransfer->setIso2Code('DE')->setEmail($email)->setFirstName('John')->setLastName('Doe')->setCellPhone('+40 175 0815')->setPhone('+30 0815')->setAddress1('Straße des 17. Juni')->setAddress2('135')->setZipCode('10623')->setSalutation(SpyPaymentPayolutionTableMap::COL_SALUTATION_MR)->setCity('Berlin');
     $payolutionPaymentTransfer = new PayolutionPaymentTransfer();
     $payolutionPaymentTransfer->setEmail($email)->setGender(SpyPaymentPayolutionTableMap::COL_GENDER_MALE)->setDateOfBirth('1970-01-02')->setClientIp('127.0.0.1')->setAccountBrand(PayolutionConstants::BRAND_INVOICE)->setLanguageIso2Code('DE')->setCurrencyIso3Code('EUR')->setAddress($paymentAddressTransfer);
     $quoteTransfer = new QuoteTransfer();
     $customerTransfer = new CustomerTransfer();
     $customerTransfer->setEmail($email);
     $customerTransfer->setIsGuest(true);
     $quoteTransfer->setCustomer($customerTransfer);
     $checkoutResponseTransfer->getSaveOrder()->setIdSalesOrder($orderEntity->getIdSalesOrder());
     $paymentTransfer = new PaymentTransfer();
     $paymentTransfer->setPayolution($payolutionPaymentTransfer);
     $quoteTransfer->setPayment($paymentTransfer);
     foreach ($orderEntity->getItems() as $orderItemEntity) {
         $itemTransfer = new ItemTransfer();
         $itemTransfer->setName($orderItemEntity->getName())->setQuantity($orderItemEntity->getQuantity())->setUnitGrossPrice($orderItemEntity->getGrossPrice())->setFkSalesOrder($orderItemEntity->getFkSalesOrder())->setIdSalesOrderItem($orderItemEntity->getIdSalesOrderItem());
         $checkoutResponseTransfer->getSaveOrder()->addOrderItem($itemTransfer);
     }
     return $quoteTransfer;
 }
コード例 #13
0
ファイル: PropelTest.php プロジェクト: spryker/Wishlist
 /**
  * @return void
  */
 public function testRemoveItem()
 {
     $wishlist = new WishlistTransfer();
     $customerTransfer = new CustomerTransfer();
     $customerTransfer->setIdCustomer(1);
     $sypWishlist = new WishlistSpy();
     $sypWishlist->setFkCustomer(1);
     $spyWishlistItem = new WishlistItemSpy();
     $spyWishlistItem->setQuantity(3);
     $spyWishlistItem->setFkProductAbstract(1);
     $spyWishlistItem->setFkProduct(1);
     $spyWishlistItem->setGroupKey(123);
     $propelStorage = new Propel($this->getWishlistQueryContainerMock($sypWishlist, $spyWishlistItem), $this->getCustomerMock(), $wishlist, $customerTransfer, $this->getProductFacadeMock());
     $wishlistChange = new WishlistChangeTransfer();
     $wishlistItem = new ItemTransfer();
     $wishlistItem->setGroupKey('123');
     $wishlistItem->setQuantity(0);
     $wishlistChange->addItem($wishlistItem);
     $propelStorage->removeItems($wishlistChange);
     $this->assertTrue($spyWishlistItem->isDelete());
 }
コード例 #14
0
ファイル: Address.php プロジェクト: spryker/Customer
 /**
  * @param \Orm\Zed\Customer\Persistence\SpyCustomer $entity
  *
  * @return \Generated\Shared\Transfer\CustomerTransfer
  */
 protected function entityToCustomerTransfer(SpyCustomer $entity)
 {
     $addressTransfer = new CustomerTransfer();
     return $addressTransfer->fromArray($entity->toArray(), true);
 }