first commit

This commit is contained in:
2026-03-05 13:07:40 +01:00
commit 64ba0721ee
25709 changed files with 4691006 additions and 0 deletions

View File

@@ -0,0 +1,35 @@
<?php
namespace WPO\WC\UBL\Transformers;
use WPO\WC\UBL\Models\Address;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
class AddressTransformer {
/**
* @return Address
*/
public function transform( \WC_Abstract_Order $item, $billing_or_shipping ) {
$model = new Address();
$model->address_1 = $item->{'get_'.$billing_or_shipping.'_address_1'}();
$model->address_2 = $item->{'get_'.$billing_or_shipping.'_address_2'}();
$model->first_name = $item->{'get_'.$billing_or_shipping.'_first_name'}();
$model->last_name = $item->{'get_'.$billing_or_shipping.'_last_name'}();
$model->city = $item->{'get_'.$billing_or_shipping.'_city'}();
$model->state = $item->{'get_'.$billing_or_shipping.'_state'}();
$model->postcode = $item->{'get_'.$billing_or_shipping.'_postcode'}();
$model->country = $item->{'get_'.$billing_or_shipping.'_country'}();
if ( 'billing' === $billing_or_shipping ) {
$model->email = $item->get_billing_email();
$model->phone = $item->get_billing_phone();
}
return $model;
}
}

View File

@@ -0,0 +1,25 @@
<?php
namespace WPO\WC\UBL\Transformers;
use WPO\WC\UBL\Models\DateTime;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
class DateTimeTransformer {
/**
* @return DateTime
*/
public function transform( \WC_Abstract_Order $item ) {
$model = new DateTime();
$model->date = $item->get_date_paid()->date( 'Y-m-d' );
$model->time = $item->get_date_paid()->date( 'H:i:s' );
$model->timezone = $item->get_date_paid()->date( 'e' );
return $model;
}
}

View File

@@ -0,0 +1,30 @@
<?php
namespace WPO\WC\UBL\Transformers;
use WPO\WC\UBL\Models\Order;
use WPO\WC\UBL\Transformers\AddressTransformer;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
class OrderTransformer {
/**
* @return Order
*/
public function transform( \WC_Abstract_Order $item ) {
$datetime_transformer = new DateTimeTransformer();
$address_transformer = new AddressTransformer();
$model = new Order();
$model->id = $item->get_id();
$model->date = $datetime_transformer->transform( $item );
$model->shipping_address = $address_transformer->transform( $item, 'shipping' );
$model->billing_address = $address_transformer->transform( $item, 'billing' );
return $model;
}
}