WC_Abstract_Order::__clone()publicWC 7.6.0

This method overwrites the base class's clone method to make it a no-op. In base class WC_Data, we are unsetting the meta_id to clone. It seems like this was done to avoid conflicting the metadata when duplicating products. However, doing that does not seems necessary for orders. In-fact, when we do that for orders, we lose the capability to clone orders with custom meta data by caching plugins. This is because, when we clone an order object for caching, it will clone the metadata without the ID. Unfortunately, when this cached object with nulled meta ID is retrieved, WC_Data will consider it as a new meta and will insert it as a new meta-data causing duplicates.

Eventually, we should move away from overwriting the __clone method in base class itself, since it's easily possible to still duplicate the product without having to hook into the __clone method.

Метод класса: WC_Abstract_Order{}

Хуков нет.

Возвращает

null. Ничего (null).

Использование

$WC_Abstract_Order = new WC_Abstract_Order();
$WC_Abstract_Order->__clone();

Список изменений

С версии 7.6.0 Введена.

Код WC_Abstract_Order::__clone() WC 8.7.0

public function __clone() {}