コード例 #1
0
ファイル: GiftCard.php プロジェクト: MikeTayC/magento.dev
 /**
  * Get checkout gift card options.
  *
  * @param GiftCardProduct $product
  * @return array
  */
 protected function getCheckoutGiftCardOptions(GiftCardProduct $product)
 {
     $checkoutGiftCardOptions = [];
     $giftcardAmounts = $product->getGiftcardAmounts();
     $checkoutData = $product->getCheckoutData();
     if (isset($checkoutData['options']['giftcard_options'])) {
         $checkoutGiftCardOptions = $checkoutData['options']['giftcard_options'];
         // Replace option key to value
         $amountOptionKey = str_replace('option_key_', '', $checkoutGiftCardOptions['giftcard_amount']);
         $checkoutGiftCardOptions['giftcard_amount'] = $giftcardAmounts[$amountOptionKey]['price'];
     }
     return $checkoutGiftCardOptions;
 }
 /**
  * Get sender and recipient fields visible errors.
  *
  * @param GiftCardProduct $product
  * @param CatalogProductView $catalogProductView
  * @return array
  */
 protected function getSenderAndRecipientFieldsVisibleErrors(GiftCardProduct $product, CatalogProductView $catalogProductView)
 {
     $giftCard = $catalogProductView->getGiftCardBlock();
     $errors = [];
     $errors[] = !$giftCard->isSenderNameVisible() ? '- "Sender Name" is not displayed.' : null;
     $errors[] = !$giftCard->isRecipientNameVisible() ? '- "Recipient Name" is not displayed.' : null;
     $errors[] = !$giftCard->isMessageVisible() ? '- "Message" is not displayed.' : null;
     if ('Physical' !== $product->getGiftcardType()) {
         $errors[] = !$giftCard->isSenderEmailVisible() ? '- "Sender Email" is not displayed.' : null;
         $errors[] = !$giftCard->isRecipientEmailVisible() ? '- "Recipient Email" is not displayed.' : null;
     }
     return $errors;
 }