@noteblock

Checkout complete: можно ли обновить поля заказа?

Задача : обновить кастомное поле профиля покупателя после оформления заказа. Значение берётся из сессии → rules не вариант.

Делаю так:
// save delivery data in order
    $url= 'http://api.boxberry.de/json.php?token=XXX&method=PointsDescription&code='.$_SESSION['bxbr_code'];
    $bxbr_info = '';
    $handle = fopen($url, "rb");
    $contents = stream_get_contents($handle);
    fclose($handle);
    $data = json_decode($contents, true);
    if (count($data) <= 0 or @$data['err']) {
      // если произошла ошибка и ответ не был получен:
      echo $data['err'];
    } else {
    	$bxbr_info .= '«'.$data['Name'].'» (код - '.$_SESSION['bxbr_code'].'): '.$data['Country'].', '.$data['Area'].', '.$data['Address'].', '.$data['Phone'];
    }
    $profile_id = $wrapper->commerce_customer_billing->profile_id->value();
  $profile = commerce_customer_profile_load($profile_id);
  if ($profile_wrapper = entity_metadata_wrapper('commerce_customer_profile', $profile)) {
    $profile_wrapper->field_delivery->set($bxbr_info);
    $profile_wrapper->save();
  }


Этот код работает на checkout/%/review и не работает на checkout/%/complete

Кто-то сталкивался? Есть пути решения?
  • Вопрос задан
  • 132 просмотра
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы