Hide Addresses

  • Posts: 200
  • Thank you received: 9
  • Hikashop Multisite
7 years 2 months ago #259802

-- HikaShop version -- : 2.6.4

On this forums i found the Hide Addresses plugin.
It works great, but i would like to hide all addresses except the default address.

So would it be possible to add something like "if address_default != 1 " in this code?

<?php
class plgHikashopAddress extends JPlugin
{
	function __construct(&$subject, $config) {
		parent::__construct($subject, $config);
	}

	function onAfterOrderCreate(&$order,&$send_email) {
		if(empty($order->order_shipping_address_id) && empty($order->order_billing_address_id))
			return true;

		$address = hikashop_get('class.address');		
		if(!empty($order->order_shipping_address_id) && $order->order_shipping_address_id != $order->order_billing_address_id) {
			$obj = new stdClass();
			$obj->address_id = $order->order_shipping_address_id;
			$obj->address_published = 0;
			$address->save($obj);
		}
		if(!empty($order->order_billing_address_id)) {
			$obj = new stdClass();
			$obj->address_id = $order->order_billing_address_id;
			$obj->address_published = 0;
			$address->save($obj);
		}
		return true;
	}
}

Please Log in or Create an account to join the conversation.

  • Posts: 81378
  • Thank you received: 13037
  • MODERATOR
7 years 2 months ago #259816

Hi,

Yes. Before the lines:
$address->save($obj);

You can add such code:

$data = $address->get($obj->address_id);
if(!$data->address_default)

Please Log in or Create an account to join the conversation.

  • Posts: 200
  • Thank you received: 9
  • Hikashop Multisite
7 years 2 months ago #260191

Thank you!

then another question:
When is an address a default?

I hoped it was the address what's used by registration, but sometimes it looks it's the shipping address.

Please Log in or Create an account to join the conversation.

  • Posts: 81378
  • Thank you received: 13037
  • MODERATOR
7 years 2 months ago #260199

Hi,

The default address is the first one entered by the customer. And then he can change it in the My addresses area on his HikaShop user control panel.

Please Log in or Create an account to join the conversation.

Time to create page: 0.062 seconds
Powered by Kunena Forum