/** * Get product ML format */ private function get_body() { // Set default fields $ml_data = array('video_id' => ML_Product::get_video_id($this->video_id)); if (!$this->is_published()) { // Fields for a new product $new_fields = array('category_id' => $this->category_id, 'currency_id' => ML()->ml_communication->get_default_currency(), 'listing_type_id' => empty($this->listing_type_id) ? 'bronze' : $this->listing_type_id, 'description' => $this->product->get_post_data()->post_content); if (!empty($this->official_store_id)) { $new_fields['official_store_id'] = $this->official_store_id; } $ml_data = array_merge($ml_data, $new_fields); } if ($this->can_update_special_fields()) { // Fields that can only be updated when the product has no sales $new_fields = array('title' => empty($this->title) ? $this->product->get_title() : $this->title, 'buying_mode' => empty($this->buying_mode) ? 'buy_it_now' : $this->buying_mode, 'condition' => empty($this->condition) ? 'new' : $this->condition, 'warranty' => $this->warranty); $this->set_shipping_fields($ml_data); $ml_data = array_merge($ml_data, $new_fields); } if (!$this->is_published() || !$this->is_variable()) { $ml_data = array_merge($ml_data, array('price' => empty($this->price) ? $this->product->get_price() : $this->price)); } if ($this->is_variable()) { return $this->get_variable_body($ml_data); } return $this->get_simple_body($ml_data); }