/**
* Implements hook_preprocess_commerce_checkout_form().
*/
function bootstrap_barrio_subtheme_preprocess_commerce_checkout_form(&$variables) {
$form = &$variables['form'];
$custom_fields = [];
// 주문 엔터티 추출 시도
$order = NULL;
$possible_keys = ['#order', 'order', '#entity', 'checkout'];
foreach ($possible_keys as $key) {
if (!empty($form[$key]) && $form[$key] instanceof \Drupal\commerce_order\Entity\OrderInterface) {
$order = $form[$key];
\Drupal::logger('mytheme')->debug('Order found with key: @key', ['@key' => $key]);
break;
}
}
// 대체 방법: 현재 체크아웃 단계에서 주문 엔터티 로드
if (!$order) {
$checkout_flow = \Drupal::routeMatch()->getParameter('commerce_checkout_flow');
if ($checkout_flow) {
$order = \Drupal::routeMatch()->getParameter('commerce_order');
\Drupal::logger('mytheme')->debug('Order loaded from route: @order_id', ['@order_id' => $order ? $order->id() : 'none']);
}
}
if ($order && $order instanceof \Drupal\commerce_order\Entity\OrderInterface) {
foreach ($order->getItems() as $order_item) {
$variation = $order_item->getPurchasedEntity();
$product = $variation ? $variation->getProduct() : NULL;
if ($product) {
$footer_block_value = $product->hasField('field_footer_block') && !$product->field_footer_block->isEmpty()
? $product->field_footer_block->value
: 'N/A';
$custom_fields[] = [
'footer_block' => $footer_block_value,
];
\Drupal::logger('mytheme')->debug('Field footer_block value: @value for product: @product_id', [
'@value' => $footer_block_value,
'@product_id' => $product->id(),
]);
}
else {
\Drupal::logger('mytheme')->debug('No product found for order item: @id', ['@id' => $order_item->id()]);
}
}
}
else {
$custom_fields[] = ['footer_block' => '주문 엔터티를 찾을 수 없습니다.'];
\Drupal::logger('mytheme')->debug('No order entity found. Form keys: @keys', ['@keys' => implode(', ', array_keys($form))]);
}
$variables['custom_fields'] = $custom_fields;
$variables['form_keys'] = array_keys($form);
}
function bootstrap_barrio_subtheme_preprocess_commerce_checkout_order_summary(&$variables) {
/** @var \Drupal\commerce_order\Entity\OrderInterface $order */
$order = $variables['order_entity'];
$result = [];
foreach ($order->getItems() as $item) {
$variation = $item->getPurchasedEntity();
// 커스텀 필드값 가져오기 (배열 형태).
$values = $variation->get('body')->getValue();
// 예: 각 라인아이템 별로 값 저장.
$result[$item->id()] = $values;
}
$variables['body'] = $result;
}
2016년 9월 뉴스레터 | 시민정치마당
주요 콘텐츠로 건너뛰기
|
 | 서울KYC 2016년 9월 뉴스레터 [28호] |
|
| 01 |  |
|
02 |  |
|
03 |  |
|
 남영동 대공분실 9월 안내 9월 24일(토) 오후 2시 하반기 안내 이어갑니다 |  순성놀이 자원봉사자 모집 순성놀이를 함께 운영할 자원봉사자가 되어주세요! |  근현대사아카데미 - 인천 2016년 마지막 답사 개항도시 인천을 찾아서 |
|
 평화길라잡이 9기 수료식 평화와 인권을 생각하며 함께 걸어갈 평화길라잡이 9기 |  일본 평화여행-요코하마 도쿄 요코하마와 도쿄에서 만난 동아시아 역사와 현재 |  KYC 살림살이&회비납부내역 서울KYC 후원해주셔서 고맙습니다^^ |
|
| |
| |
|
본 메일은 서울KYC 회원 및 뉴스레터 신청자에게 발송되었습니다. |
뉴스레터의 수신을 더이상 원하지 않으시면, 하단의 '수신거부' 버튼을 클릭해주세요. To unsubscribe. please click the 'Unsubscribe' button. |
| |
|
댓글 쓰기
댓글 달기