Generating a truly unique order id in PHP?
By : xxywy
Date : March 29 2020, 07:55 AM
|
Generating Order Numbers - Keep unique across multiple machines - Unique string seed
By : Ipunk Giejee
Date : March 29 2020, 07:55 AM
Any of those help If you have a relatively small number of machines and each one can have it's own configuration file or setting, you can assign a letter to each machine (A,B,C...) and then append the letter onto the order number, which could just be an auto-incrementing integer in each DB. i.e. code :
Starting each database ID at 1000:
1001A // First order on database A
1001B // First order on database B
1001C // First order on database C
1002A // Second order on database A
1003A // Third order on database A
1004A // etc...
1002B
1002C
|
Generating Unique Order Number
By : Thamis
Date : March 29 2020, 07:55 AM
around this issue I am trying to upload the cover image of a Facebook Page via Graph API, But it appears on the Timeline once its updated. code :
while (!empty($order_no_exisits)) {
$unique_order_number = strtoupper(substr(md5(microtime()), 0, 8));
if(!$this->Order->find('first', array('order_no' => $unique_order_number)))
exit;
}
|
How to add Unique nos in order email for each unit of woocommerce product sold
By : igi
Date : March 29 2020, 07:55 AM
it helps some times I found a solution if this helpful for you. I think you can store unique nos in database order item meta when product sold. Put this hook in your active theme functions.php file. code :
add_action( 'woocommerce_add_order_item_meta', 'add_random_number_item_meta', 10, 2 );
function add_random_number_item_meta( $item_id, $item_data ){
// store each product item quantity in array
$random = array();
for( $i = 0; $i < $item_data['quantity']; $i++ )
$random[$i] = rand(10000, 90000);
// save unique numbers array each order item
wc_add_order_item_meta( $item_id, '_unique_nos', $random );
}
//woocommerce\emails\email-order-items.php
$unique_numbers = wc_get_order_item_meta( $item_id, '_unique_nos', true );
echo implode( "," , $unique_numbers );
// This will be same both for admin or customer
|
Order items in a JS tracking code on Order received page in Woocommerce
By : user1924432
Date : March 29 2020, 07:55 AM
will be helpful for those in need The following revisited code adds the correct order items loop and uses "Order received" page (Thankyou) dedicated action hook: code :
add_action( 'woocommerce_thankyou', 'js_tracking_thank_you_page', 90, 1 );
function js_tracking_thank_you_page( $order_id ) {
// Get the WC_Order instance Object
$order = wc_get_order( $order_id );
// Output
?>
<script type="text/javascript">
ADMITAD = window.ADMITAD || {};
ADMITAD.Invoice = ADMITAD.Invoice || {};
// deduplication parameter (for Admitad by default)
ADMITAD.Invoice.broker = "adm";
// action code (defined during integration)
ADMITAD.Invoice.category = "1";
// temporary array for product items
var orderedItem = [];
<?php
// Loop through Order items
foreach( $order->get_items() as $item ) :
$product = $item->get_product();
?>
orderedItem.push({
Product: {
// internal product ID (not more than 100 characters, the same as in your product feed)
productID: '<?php echo $item->get_product_id(); ?>',
// tariff code (defined during integration)
category: '1',
// product price
price: '<?php echo $product->get_price(); ?>',
// currency code in the ISO-4217 alfa-3 format
priceCurrency: '<?php echo $order->get_currency(); ?>',
},
// product quantity
orderQuantity: '<?php echo $item->get_quantity(); ?>',
additionalType: "sale" // always sale
});
<?php endforeach; // End of Loop ?>
// adding items to the order
ADMITAD.Invoice.referencesOrder = ADMITAD.Invoice.referencesOrder || [];
ADMITAD.Invoice.referencesOrder.push({
// internal order ID (not more than 100 characters)
orderNumber: "<?php echo $order->get_id(); ?>;",
orderedItem: orderedItem
});
// Important! If order data is loaded via AJAX, uncomment this string.
// ADMITAD.Tracking.processPositions();
</script>
<?php
}
// product price
price: '<?php echo $product->get_price(); ?>',
// Converted product price (rounded with 2 decimals)
<?php $price = EuroFxRef::convert( $product->get_price(), 'RON', 'EUR' ); ?>
price: '<?php echo round( $price, 2 ); ?>',
|