I’m trying to change the random barcode generated in a plugin to reflect the relevant order number ( order_id ) and not generate a unique number.
The current code that sets the variable ($barcode_string) looks like this:
// Get unqiue barcode string
$barcode_string = $this->get_barcode_string();
And then generates a unique number for it here:
/**
* Get text string for barcode
* @access public
* @since 1.0.0
* @return void
*/
public function get_barcode_string () {
// Use PHP's uniqid() for the barcode
$barcode_string = uniqid();
// Check if this barcode already exists and add increment if so
$existing_order_id = $this->get_barcode_order( $barcode_string );
$orig_string = $barcode_string;
$i = 1;
while( $existing_order_id != 0 ) {
$barcode_string = $orig_string . $i;
$existing_order_id = $this->get_barcode_order( $barcode_string );
++$i;
}
// Return unique barcode
return apply_filters( $this->_token . '_barcode_string', $barcode_string );
} // End get_barcode_string ()
So, I imagine that I need to make the variable “$barcode_string” equal to “order_id”. But I’m battling to find a simple guide on doing that.
Any help please?