/** * Metabox for coupons client */ public function meta_box_coupons() { global $meta, $barcode, $post_ID, $wpdb, $table_prefix; $continue = false; require_once 'wps_barcodegen.ctr.php'; $barcode = new wps_barcodegen(); $country = '000'; $result = get_post_meta($post_ID); if (!empty($result)) { if (empty($result['wpshop_coupon_barcode'])) { $conf = get_option('wps_barcode'); if ($conf['type'] === 'internal') { $type = $conf['internal_coupons']; $query = $wpdb->get_results('SELECT post_date FROM ' . $table_prefix . 'posts WHERE ID=' . $post_ID, ARRAY_A); $pDate = new DateTime($query[0]['post_date']); $date = $pDate->format('my'); } $len = strlen($post_ID); $ref = ''; if ($len < 5) { for ($i = 0; $i <= $len; $i++) { $ref .= '0'; } } $id = $ref . $post_ID; $code = $type . $date . $id; $meta = $barcode->checksum($code); add_post_meta($post_ID, 'wpshop_coupon_barcode', $meta); } else { $meta = $result['wpshop_coupon_barcode'][0]; } $post = get_post($post_ID, ARRAY_A); $this->generate_image($barcode, $meta, __('coupon', 'wps_barcode'), $result['wpshop_coupon_discount_value'][0], $post['post_title'], $post_ID); } else { echo '<p>' . __('None bardcode generated as coupon has not created.', 'wps_barcode') . '</p>'; } }
private function wps_generate_barcode($array) { include_once 'wps_barcodegen.ctr.php'; $code = ''; $ref = ''; $barcode = new wps_barcodegen(); $conf = get_option('wps_barcode'); if (array_key_exists('normal', $array)) { $code .= $array['normal']['country']; $code .= $array['normal']['enterprise']; $code .= $array['normal']['ID']; $id = $array['normal']['ID']; } else { if (array_key_exists('internal', $array)) { $code .= $array['internal']['type']; $code .= $array['internal']['date']; $code .= $array['internal']['ID']; $id = $array['internal']['ID']; } } $gencode = $barcode->checksum($code); $barcode->writeLog(sprintf(__("Checksum generate: %s from %s <br />", 'wps_barcode'), '<b>' . $gencode . '</b>', '<b>' . $code . '</b>')); $message = sprintf(__("Log generated by wps_barcodegen for add/update product: <br /> %s", 'wps_barcode'), $barcode->getLog()); if (class_exists('wpeologs_ctr')) { wpeologs_ctr::log_datas_in_files('wps_barcode', array('object_id' => $id, 'message' => $message), 0); } return $gencode; }