Woocommerce - Changing formatted_billing_address output/display?
In woocommerce using "formatted_billing_address" results in the billing
address being displayed. Issue is it places each item on its own line by
default such as:
John Doe
Company Name
123 Maple Ln
Toronto
Ontario
G8R 1J8
I would like to change the way its displayed, but cant manage to find
where it comes from or how I can do this, I want to have more then one
item on a line?
/**
287 * Get a formatted billing address for the order.
288 *
289 * @access public
290 * @return string
291 */
292 public function get_formatted_billing_address() {
293 if ( ! $this->formatted_billing_address ) {
294 global $woocommerce;
295
296 // Formatted Addresses
297 $address = apply_filters(
'woocommerce_order_formatted_billing_address', array(
298 'first_name' => $this->billing_first_name,
299 'last_name' => $this->billing_last_name,
300 'company' => $this->billing_company,
301 'address_1' => $this->billing_address_1,
302 'address_2' => $this->billing_address_2,
303 'city' => $this->billing_city,
304 'state' => $this->billing_state,
305 'postcode' => $this->billing_postcode,
306 'country' => $this->billing_country
307 ), $this );
308
309 $this->formatted_billing_address =
$woocommerce->countries->get_formatted_address( $address );
310 }
311 return $this->formatted_billing_address;
312 }
313
314 /**
315 * Get the billing address in an array.
316 *
317 * @access public
318 * @return array
319 */
320 public function get_billing_address() {
321 if ( ! $this->billing_address ) {
322 // Formatted Addresses
323 $address = array(
324 'address_1' => $this->billing_address_1,
325 'address_2' => $this->billing_address_2,
326 'city' => $this->billing_city,
327 'state' => $this->billing_state,
328 'postcode' => $this->billing_postcode,
329 'country' => $this->billing_country
330 );
331 $joined_address = array();
332 foreach ($address as $part) if (!empty($part))
$joined_address[] = $part;
333 $this->billing_address = implode(', ', $joined_address);
334 }
335 return $this->billing_address;
336 }
337
338 /**
339 * Get a formatted shipping address for the order.
340 *
341 * @access public
342 * @return void
343 */
344 public function get_formatted_shipping_address() {
345 if ( ! $this->formatted_shipping_address ) {
346 if ( $this->shipping_address_1 ) {
347 global $woocommerce;
348
349 // Formatted Addresses
350 $address = apply_filters(
'woocommerce_order_formatted_shipping_address', array(
351 'first_name' => $this->shipping_first_name,
352 'last_name' => $this->shipping_last_name,
353 'company' => $this->shipping_company,
354 'address_1' => $this->shipping_address_1,
355 'address_2' => $this->shipping_address_2,
356 'city' => $this->shipping_city,
357 'state' => $this->shipping_state,
358 'postcode' => $this->shipping_postcode,
359 'country' => $this->shipping_country
360 ), $this );
361
362 $this->formatted_shipping_address =
$woocommerce->countries->get_formatted_address( $address );
363 }
364 }
365 return $this->formatted_shipping_address;
366 }
367
368
No comments:
Post a Comment