tewst.php - PHP Online
Form of PHP Sandbox
*** This page was generated with the meta tag "noindex, nofollow". This happened because you selected this option before saving or the system detected it as spam. This means that this page will never get into the search engines and the search bot will not crawl it. There is nothing to worry about, you can still share it with anyone.
Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php
in the places where the PHP script should be executed.
Result of php executing
Full code of tewst.php.php
- <?php
- if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
- class CrmErpSolutionProProducts{
- public $plugin = 'CrmErpSolutionPro';
- public $slug = 'crm-erp-business-solution-pro';
- public $enableProducts ='enableProducts';
- public function __construct() {
- if( get_option( $this->plugin.$this->enableProducts ) ){
- add_action( "init", array($this,"offlineProducts" ) );
- add_action( "admin_init", array( $this,"metaBox" ) );
- add_action( "admin_init", array( $this,"init" ) );
- add_action( "save_post", array( $this,"saveFields" ) );
- add_action( 'admin_menu', array( $this,'menu_page') );
- add_filter( 'manage_offline_products_posts_columns', array( $this,'addColumnHeader' ) );
- add_filter( "manage_edit-offline_products_sortable_columns", array( $this,"addColumnHeader" ) );
- add_filter( "manage_offline_products_columns", array( $this,"column_order" ) );
- add_filter( 'manage_edit-offline_products_columns', array( $this,"column_order" ) );
- add_filter( 'pre_get_posts', array($this,'searchfilter') );
- add_action( 'wp_ajax_nopriv_displayProducts', array( $this,'displayProducts' ) );
- add_action( 'wp_ajax_displayProducts', array( $this,'displayProducts' ) );
- add_action( 'wp_ajax_nopriv_getProducts', array( $this,'displaySoldProductsTransactions' ) );
- add_action( 'wp_ajax_getProducts', array( $this,'displaySoldProductsTransactions' ) );
- add_action( 'wp_ajax_nopriv_getProducts', array( $this,'displaySoldProductsEshop' ) );
- add_action( 'wp_ajax_getProducts', array( $this,'displaySoldProductsEshop' ) );
- }
- }
- public function init(){
- if( get_option( $this->plugin.$this->enableProducts ) ){
- add_action( 'restrict_manage_posts', array( $this,'crmpro_filter_products' ) , 10, 2);
- add_action( 'manage_offline_products_posts_custom_column', array( $this,'addAdColumns' ),10,2 );
- }
- }
- public function offlineProducts(){
- register_post_type( 'offline_products',
- array(
- 'labels' => array(
- 'name' => esc_html__( 'Offline Products' ,'CrmErpSolutionPro' ),
- 'singular_name' => esc_html__( 'Offline Product','CrmErpSolutionPro' ),
- 'search_items' => esc_html__( 'Search Offline Products' ,'CrmErpSolutionPro' ),
- 'all_items' => esc_html__( 'All Offline Products' ,'CrmErpSolutionPro' ),
- 'parent_item' => esc_html__( 'Parent Offline Product','CrmErpSolutionPro' ),
- 'parent_item_colon' => esc_html__( 'Parent Offline Product:','CrmErpSolutionPro' ),
- 'edit_item' => esc_html__( 'Edit Offline Product', 'CrmErpSolutionPro' ),
- 'update_item' => esc_html__( 'Update Offline Product' , 'CrmErpSolutionPro' ),
- 'add_new_item' => esc_html__( 'Add New Offline Product' , 'CrmErpSolutionPro' ),
- 'add_new' => esc_html__( 'New Offline Product', 'CrmErpSolutionPro' ),
- 'new_item_name' => esc_html__( 'New Offline Product Name', 'CrmErpSolutionPro' ),
- 'new_item' => esc_html__( 'New Offline Product', 'CrmErpSolutionPro' ),
- 'menu_name' => esc_html__( 'Offline Products', 'CrmErpSolutionPro' ),
- 'not_found' => esc_html__('No Products found', 'CrmErpSolutionPro' ),
- ),
- 'description' => esc_html__( 'Adding and editing my Offline Products', 'CrmErpSolutionPro' ),
- 'menu_icon' => 'dashicons-tag',
- 'supports' => array( 'title', 'thumbnail' ),
- 'show_in_rest' => true,
- 'rest_base' => 'offline_products',
- 'rest_controller_class' => 'WP_REST_Posts_Controller',
- 'capability_type' => 'page',
- 'hierarchical' => false,
- 'menu_position' => null,
- 'public' => false, // it's not public, it shouldn't have it's own permalink, and so on
- 'publicly_queryable' => true, // you should be able to query it
- 'show_ui' => true, // you should be able to edit it in wp-admin
- //'show_in_menu' => false,
- 'menu_position' => null,
- 'show_in_menu' => false,
- 'exclude_from_search' => true, // you should exclude it from search results
- 'show_in_nav_menus' => false, // you shouldn't be able to add it to menus
- 'has_archive' => true, // it shouldn't have archive page
- 'rewrite' => false, // it shouldn't have rewrite rules
- )
- );
- $labels = array(
- 'name' => _x( 'Category', 'CrmErpSolutionPro' ),
- 'singular_name' => _x( 'Category', 'CrmErpSolutionPro' ),
- 'search_items' => esc_html__( 'Search Category','CrmErpSolutionPro' ),
- 'all_items' => esc_html__( 'All Category' , 'CrmErpSolutionPro' ),
- 'parent_item' => esc_html__( 'Parent Category' , 'CrmErpSolutionPro' ),
- 'parent_item_colon' => esc_html__( 'Parent Category:' , 'CrmErpSolutionPro' ),
- 'edit_item' => esc_html__( 'Edit Category', 'CrmErpSolutionPro' ),
- 'update_item' => esc_html__( 'Update Category', 'CrmErpSolutionPro' ),
- 'add_new_item' => esc_html__( 'Add New Category', 'CrmErpSolutionPro' ),
- 'new_item_name' => esc_html__( 'New Type Category', 'CrmErpSolutionPro' ),
- 'menu_name' => esc_html__( 'Category' , 'CrmErpSolutionPro' ),
- );
- register_taxonomy( 'off_prod_cat', array( 'offline_products' ), array(
- 'hierarchical' => false,
- 'labels' => $labels,
- 'show_admin_column' => true,
- 'query_var' => true,
- 'public' => false, // it's not public, it shouldn't have it's own permalink, and so on
- 'publicly_queryable' => true, // you should be able to query it
- 'show_ui' => true, // you should be able to edit it in wp-admin
- 'exclude_from_search' => true, // you should exclude it from search results
- 'show_in_nav_menus' => false, // you shouldn't be able to add it to menus
- 'has_archive' => false, // it shouldn't have archive page
- 'rewrite' => false, // it shouldn't have rewrite rules
- ));
- $labels = array(
- 'name' => _x( 'Brand', $this->plugin ),
- 'singular_name' => _x( 'Brand', 'CrmErpSolutionPro' ),
- 'search_items' => esc_html__( 'Search Brand', 'CrmErpSolutionPro' ),
- 'all_items' => esc_html__( 'All Brand' , 'CrmErpSolutionPro' ),
- 'parent_item' => esc_html__( 'Parent Brand' , 'CrmErpSolutionPro' ),
- 'parent_item_colon' => esc_html__( 'Parent Brand:' , 'CrmErpSolutionPro' ),
- 'edit_item' => esc_html__( 'Edit Brand', 'CrmErpSolutionPro' ),
- 'update_item' => esc_html__( 'Update Brand', 'CrmErpSolutionPro' ),
- 'add_new_item' => esc_html__( 'Add New Brand', 'CrmErpSolutionPro' ),
- 'new_item_name' => esc_html__( 'New Type Brand', 'CrmErpSolutionPro' ),
- 'menu_name' => esc_html__( 'Brand' , 'CrmErpSolutionPro' ),
- );
- register_taxonomy( 'off_prod_brand', array( 'offline_products' ), array(
- 'hierarchical' => false,
- 'labels' => $labels,
- 'show_admin_column' => true,
- 'query_var' => true,
- 'public' => false, // it's not public, it shouldn't have it's own permalink, and so on
- 'publicly_queryable' => true, // you should be able to query it
- 'show_ui' => true, // you should be able to edit it in wp-admin
- 'exclude_from_search' => true, // you should exclude it from search results
- 'show_in_nav_menus' => false, // you shouldn't be able to add it to menus
- 'has_archive' => false, // it shouldn't have archive page
- 'rewrite' => false, // it shouldn't have rewrite rules
- 'supports' => array( 'title', 'editor', 'image' ),
- ));
- }
- public function crmpro_filter_products( $post_type, $which ) {
- // Apply this only on a specific post type
- if ( 'offline_products' !== $post_type )
- return;
- // A list of taxonomy slugs to filter by
- $taxonomies = array( 'off_prod_brand', 'off_prod_cat' );
- foreach ( $taxonomies as $taxonomy_slug ) {
- // Retrieve taxonomy data
- $taxonomy_obj = get_taxonomy( $taxonomy_slug );
- $taxonomy_name = $taxonomy_obj->labels->name;
- // Retrieve taxonomy terms
- $terms = get_terms( $taxonomy_slug );
- // Display filter HTML
- echo "<select name='{$taxonomy_slug}' id='{$taxonomy_slug}' class='postform'>";
- echo '<option value="">' . sprintf( esc_html__( 'Show All %s', 'CrmErpSolutionPro' ), $taxonomy_name ) . '</option>';
- foreach ( $terms as $term ) {
- printf(
- '<option value="%1$s" %2$s>%3$s (%4$s)</option>',
- $term->slug,
- ( ( isset( $_GET[$taxonomy_slug] ) && ( $_GET[$taxonomy_slug] == $term->slug ) ) ? ' selected="selected"' : '' ),
- $term->name,
- $term->count
- );
- }
- echo '</select>';
- }
- }
- public function getProducts( $id ){
- $args = array(
- 'post_type' => array( 'product','offline_products' ),
- 'orderby' => 'ASC',
- 'post__in' => $id
- );
- $loop = new WP_Query( $args );
- while ( $loop->have_posts() ) : $loop->the_post();
- global $product;
- global $post;
- global $woocommerce;
- if (get_post_type( get_the_ID() ) == 'product' ){
- $price = get_post_meta( get_the_ID(), '_price', true);
- $stock = get_post_meta( get_the_ID(), '_stock', true);
- $wholesaleprice = get_post_meta( get_the_ID(), $this->plugin.'wholesaleprice', true );
- }else{
- $price = get_post_meta( get_the_ID(), $this->plugin.'price', true );
- $wholesaleprice = get_post_meta( get_the_ID(), $this->plugin.'wholesaleprice', true );
- $stock = get_post_meta( get_the_ID(), $this->plugin.'quantity', true );
- }
- if ( get_post_type( get_the_ID() ) == 'product' ){
- $product = wc_get_product( get_the_ID() );
- if ( is_singular( 'product' ) ) {
- echo "<option stock='".$stock."' wholesaleprice='".$wholesaleprice."' price='".$price."' value='".get_the_ID()."'>".get_the_title()."</option>";
- }else{
- $product = new WC_Product_Variable( get_the_ID() );
- $variations = $product->get_available_variations();
- foreach ( $variations as $variation ) {
- foreach($variation['attributes'] as $key=>$value){
- }
- $attributes = implode('', array_map(
- function ($v, $k) {
- if(is_array($v)){
- return $k.'[]='.implode(' '.str_replace("attribute_pa_","",$k).'[]=', $v);
- }else{
- return " ".str_replace("attribute_pa_","",$k).'='.$v;
- }
- },
- $variation['attributes'],
- array_keys($variation['attributes'])
- ));
- $variationId = $variation['variation_id'];
- echo "<option stock='".$stock."' wholesaleprice='".$wholesaleprice."' price='".$price."' value='".$variationId."'>".get_the_title().": ". implode(', ',$variation['attributes'])."</option>";
- }
- }
- }else{
- echo "<option stock='".$stock."' wholesaleprice='".$wholesaleprice."' price='".$price."' value='".get_the_ID()."'>".get_the_title()."</option>";
- }
- endwhile;
- wp_reset_query();
- }
- public function searchProductForm(){
- ?>
- <i class='fa fa-search productsearch' style='width:10%;cursor:pointer;'></i>
- <input type="text" id="searchproduct" style='width:85%' name="searchproduct" placeholder='<?php esc_html_e( "Select product: search by sku/name", 'CrmErpSolutionPro' ); ?>' />
- <select id='product' style='display:none;width:100%' name='product' class="code "></select>
- <?php
- }
- public function searchfilter($query) {
- if( $title = $query->get( '_meta_or_title' ) )
- {
- add_filter( 'get_meta_sql', function( $sql ) use ( $title )
- {
- global $wpdb;
- // Only run once:
- static $nr = 0;
- if( 0 != $nr++ ) return $sql;
- // Modify WHERE part:
- $sql['where'] = sprintf(
- " AND ( %s OR %s ) ",
- $wpdb->prepare( "{$wpdb->posts}.post_title = '%s'", $title ),
- mb_substr( $sql['where'], 5, mb_strlen( $sql['where'] ) )
- );
- return $sql;
- });
- }
- }
- public function displayProducts(){
- if( isset( $_REQUEST['searchproduct'] ) && !empty( $_REQUEST['searchproduct'] ) ){
- $product = sanitize_text_field( $_REQUEST['searchproduct'] );
- $args = array(
- 'post_type' => array('product','offline_products' ),
- 'posts_per_page' => -1,
- 'post_status' => 'publish',
- '_meta_or_title' => $product,
- 'meta_query' => array(
- 'relation' => 'OR',
- array(
- 'key' => '_sku',
- 'value' => $product,
- 'compare' => 'LIKE'
- ),
- array(
- 'key' => $this->plugin.'quantity',
- 'value' => $product,
- 'compare' => 'LIKE'
- ),
- ),
- );
- $loop = new WP_Query( $args );
- while ( $loop->have_posts() ) : $loop->the_post();
- global $product;
- global $post;
- global $woocommerce;
- if ( get_post_type( get_the_ID() ) == 'product' ){
- }else{
- $price = get_post_meta( get_the_ID(), $this->plugin.'price', true );
- $stock = get_post_meta( get_the_ID(), $this->plugin.'quantity', true );
- $wholesaleprice = get_post_meta( get_the_ID(), $this->plugin.'wholesaleprice', true );
- }
- if ( get_post_type( get_the_ID() ) == 'product' ){
- $product = wc_get_product( get_the_ID() );
- if ( $product->is_type( 'simple' ) || $product->is_type( 'external' ) ) {
- $price = get_post_meta( get_the_ID(), '_price', true );
- $stock = get_post_meta( get_the_ID(), '_stock', true );
- $wholesaleprice = get_post_meta( get_the_ID(), $this->plugin.'wholesaleprice', true );
- echo "<option stock='".$stock."' sku = '".get_post_meta( get_the_ID(), '_sku', true )."' wholesaleprice='".$wholesaleprice."' price='".$price."' value='".get_the_ID()."'>".get_the_title()."</option>";
- }else{
- $product = new WC_Product_Variable( get_the_ID() );
- $variations = $product->get_available_variations();
- foreach ( $variations as $variation ) {
- $price = get_post_meta( $variation['variation_id'], '_price', true);
- $stock = get_post_meta( $variation['variation_id'], '_stock', true);
- $wholesaleprice = get_post_meta( $variation['variation_id'], $this->plugin.'wholesaleprice', true);
- foreach($variation['attributes'] as $key=>$value){
- }
- $attributes = implode('', array_map(
- function ($v, $k) {
- if(is_array($v)){
- return $k.'[]='.implode(' '.str_replace("attribute_pa_","",$k).'[]=', $v);
- }else{
- return " ".str_replace("attribute_pa_","",$k).'='.$v;
- }
- },
- $variation['attributes'],
- array_keys($variation['attributes'])
- ));
- $variationId = $variation['variation_id'];
- echo "<option stock='".$stock."' sku = '".get_post_meta( $variation['variation_id'], '_sku', true)."' wholesaleprice='".$wholesaleprice."' price='".$price."' value='".$variationId."'>".get_the_title().": ". implode(', ',$variation['attributes'])."</option>";
- }
- }
- }else{
- echo "<option stock='".$stock."' sku = '".get_post_meta( get_the_ID(), $this->plugin.'sku', true )."' wholesaleprice='".$wholesaleprice."' price='".$price."' value='".get_the_ID()."'>".get_the_title()."</option>";
- }
- endwhile;
- wp_reset_query();
- }
- }
- public function displaySoldProducts(){
- if( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'getProducts' ){
- if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
- global $woocommerce;
- $filters = array(
- 'post_status' => array( 'wc-completed'),
- 'post_type' => 'shop_order',
- 'posts_per_page' => -1,
- 'paged' => 1,
- 'orderby' => 'modified',
- 'order' => 'ASC',
- );
- $loop = new WP_Query( $filters );
- if ( get_post_type( get_the_ID() ) == 'product' ){
- $price = get_post_meta( get_the_ID(), '_price', true );
- $stock = get_post_meta( get_the_ID(), '_stock', true );
- $wholesaleprice = get_post_meta( get_the_ID(), $this->plugin.'wholesaleprice', true );
- }else{
- $price = get_post_meta( get_the_ID(), $this->plugin.'price', true );
- $wholesaleprice = get_post_meta( get_the_ID(), $this->plugin.'wholesaleprice', true );
- $stock = get_post_meta( get_the_ID(), $this->plugin.'quantity', true );
- }
- if( $loop->have_posts() ){
- $products=array();
- while ( $loop->have_posts() ) {
- $loop->the_post();
- $order = new WC_Order( $loop->post->ID );
- $items = $order->get_items();
- foreach( $items as $product ) {
- if( !in_array( $product['product_id'] ,$products ) ){
- array_push( $products, $product['product_id'] );
- echo "<option sku = '".get_post_meta( $product['product_id'], '_sku', true )."' value='".$product['product_id']."'>".$product['name']."</option>";
- }
- }
- }
- }
- }
- global $wpdb;
- $table_name = $wpdb->prefix . 'crm_transaction_items'; // do not forget about tables prefix
- $result = $wpdb->get_results( "SELECT DISTINCT product_id FROM ".$table_name." " );
- if( $result ){
- foreach( $result as $res ) {
- echo "<option sku = '".get_post_meta( $res->product_id, $this->plugin.'sku', true )."' value='".$res->product_id."'>".get_the_title( $res->product_id )."</option>";
- }
- }
- }
- }
- public function displaySoldProductsTransactions(){
- if( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'getProducts' ){
- global $wpdb;
- $table_name = $wpdb->prefix . 'crm_transaction_items'; // do not forget about tables prefix
- $result = $wpdb->get_results("SELECT DISTINCT product_id FROM ".$table_name." ");
- if( $result ){
- foreach( $result as $res ) {
- echo "<option sku = '".get_post_meta( $res->product_id, $this->plugin.'sku', true)."' value='".$res->product_id."'>".get_the_title($res->product_id )."</option>";
- }
- }
- }
- }
- public function displaySoldProductsEshop(){
- if(isset($_REQUEST['action']) && $_REQUEST['action']='getProducts' ){
- global $woocommerce;
- $filters = array(
- 'post_status' => array( 'wc-completed'),
- 'post_type' => 'shop_order',
- 'posts_per_page' => -1,
- 'paged' => 1,
- 'orderby' => 'modified',
- 'order' => 'ASC',
- );
- $loop = new WP_Query($filters);
- if ( get_post_type( get_the_ID() ) == 'product' ){
- $price = get_post_meta( get_the_ID(), '_price', true);
- $stock = get_post_meta( get_the_ID(), '_stock', true);
- $wholesaleprice = get_post_meta( get_the_ID(), $this->plugin.'wholesaleprice', true);
- }else{
- $price = get_post_meta( get_the_ID(), $this->plugin.'price', true);
- $wholesaleprice = get_post_meta( get_the_ID(), $this->plugin.'wholesaleprice', true);
- $stock = get_post_meta( get_the_ID(), $this->plugin.'quantity', true);
- }
- if($loop->have_posts()){
- $products=array();
- while ($loop->have_posts()) {
- $loop->the_post();
- $order = new WC_Order($loop->post->ID);
- $items = $order->get_items();
- foreach( $items as $product ) {
- if( !in_array( $product['product_id'] ,$products ) ){
- array_push($products, $product['product_id'] );
- echo "<option sku = '".get_post_meta( $product['product_id'], '_sku', true)."' value='".$product['product_id']."'>".$product['name']."</option>";
- }
- }
- }
- }
- }
- }
- public function metaBox($post){
- add_meta_box("prodPrice", __('Product Info',$this->plugin), array($this,"priceCreate" ) , "offline_products", "normal", "high");
- }
- public function addColumnHeader( $columns ) {
- $columns['Image'] = 'Image';
- $columns['SKU'] = 'Sku';
- $columns['Brand'] = 'Brand';
- $columns['Category'] = 'Category';
- $columns['WholesalePrice'] = 'Wholesale Price';
- $columns['Price'] = 'Retail Price';
- $columns['Stock'] = 'Stock';
- return $columns;
- }
- public function addAdColumns( $column_name, $post_id ) {
- global $post;
- if( $column_name == 'Image' ) {
- $image = get_the_post_thumbnail( $post_id, array( 30, 30) );
- if($image !='') {
- print get_the_post_thumbnail( $post_id, array( 30, 30) );
- }
- }
- if( $column_name == 'SKU' ) {
- $sku = get_post_meta( $post_id, $this->plugin.'sku', true );
- if($sku !='') {
- echo esc_attr($sku);
- }
- }
- if( $column_name == 'WholesalePrice' ) {
- $price = get_post_meta( $post_id, $this->plugin.'wholesaleprice', true );
- if($price !='') {
- echo esc_attr($price);
- }
- }
- if( $column_name == 'Price' ) {
- $price = get_post_meta( $post_id, $this->plugin.'price', true );
- if($price !='') {
- echo esc_attr($price);
- }
- }
- if( $column_name == 'Stock' ) {
- $quantity = get_post_meta( $post_id, $this->plugin.'quantity', true );
- if($quantity !='') {
- echo esc_attr($quantity);
- }
- }
- if( $column_name == 'Category' ) {
- $terms = get_the_terms( $post_id, 'off_prod_cat' );
- if ( $terms && ! is_wp_error( $terms ) ) :
- $draught_links = array();
- foreach ( $terms as $term ) {
- $draught_links[] = $term->name;
- }
- $on_draught = join( ", ", $draught_links );
- ?>
- <p class="">
- <?php printf( esc_html__( '%s', 'textdomain' ), esc_html( $on_draught ) ); ?>
- </p>
- <?php endif;
- }
- if( $column_name == 'Brand' ) {
- $terms = get_the_terms( $post_id, 'off_prod_brand' );
- if ( $terms && ! is_wp_error( $terms ) ) :
- $draught_links = array();
- foreach ( $terms as $term ) {
- $draught_links[] = $term->name;
- }
- $on_draught = join( ", ", $draught_links );
- ?>
- <p class="">
- <?php printf( esc_html__( '%s', 'textdomain' ), esc_html( $on_draught ) ); ?>
- </p>
- <?php endif;
- }
- }
- public function column_order($columns) {
- unset( $columns );
- $columns = array(
- 'cb' => '<input type="checkbox" />', //Render a checkbox instead of text
- //'id' => __('ID', $this->plugin),
- 'Image' => __('Image', $this->plugin),
- 'title' => __('Title', $this->plugin),
- 'Brand' => __('Brand', $this->plugin),
- 'Category' => __('Category', $this->plugin),
- 'SKU' => __('SKU', $this->plugin),
- 'WholesalePrice' => __('Wholesale Price', $this->plugin),
- 'Price' => __('Retail Price', $this->plugin),
- 'Stock' => __('Stock', $this->plugin),
- 'Date' => __('Date', $this->plugin),
- );
- return $columns;
- }
- public function priceCreate($post){
- $sku = get_post_meta($post->ID, $this->plugin.'sku' , true ) ;
- ?> <p><label ><?php _e('SKU', $this->plugin)?></label> <input placeholder='sku' name='<?php print $this->plugin."sku";?>' value='<?php print esc_attr($sku); ?>' /></p> <?php
- $wholesaleprice = get_post_meta($post->ID, $this->plugin.'wholesaleprice' , true ) ;
- ?> <p><label ><?php _e('Wholesale Price', $this->plugin)?></label> <input required placeholder='price' name='<?php print $this->plugin."wholesaleprice";?>' value='<?php print esc_attr($wholesaleprice); ?>' /></p> <?php
- $price = get_post_meta($post->ID, $this->plugin.'price' , true ) ;
- ?> <p><label ><?php _e('Retail Price', $this->plugin)?></label> <input required placeholder='price' name='<?php print $this->plugin."price";?>' value='<?php print esc_attr($price); ?>' /></p> <?php
- $quantity = get_post_meta($post->ID, $this->plugin.'quantity' , true ) ;
- ?> <p><label ><?php _e('Stock', $this->plugin)?></label> <input required placeholder='quantity' name='<?php print $this->plugin."quantity";?>' value='<?php print esc_attr($quantity); ?>' /></p> <?php
- }
- public function saveFields(){
- global $post;
- if(isset($_POST[$this->plugin.'sku'])){
- if (!empty($_POST[$this->plugin.'sku']) ) {
- $sku = htmlspecialchars(sanitize_textarea_field($_POST[$this->plugin.'sku']) );
- update_post_meta($post->ID, $this->plugin.'sku', $sku);
- }
- }
- if(isset($_POST[$this->plugin.'quantity'])){
- if (!empty($_POST[$this->plugin.'quantity']) ) {
- $quantity = htmlspecialchars(sanitize_textarea_field($_POST[$this->plugin.'quantity']) );
- update_post_meta($post->ID, $this->plugin.'quantity', $quantity);
- }
- }
- if(isset($_POST[$this->plugin.'price'])){
- if (!empty($_POST[$this->plugin.'price']) ) {
- $price=sanitize_text_field($_POST[$this->plugin.'price']);
- update_post_meta($post->ID, $this->plugin.'price', $price);
- }
- }
- if(isset($_POST[$this->plugin.'wholesaleprice'])){
- if (!empty($_POST[$this->plugin.'wholesaleprice']) ) {
- $wholesaleprice=sanitize_text_field($_POST[$this->plugin.'wholesaleprice']);
- update_post_meta($post->ID, $this->plugin.'wholesaleprice', $wholesaleprice);
- }
- }
- }
- public function menu_page() {
- add_submenu_page( $this->slug, esc_html__("Offline Products", $this->plugin ), esc_html__("Offline Products", $this->plugin), $this->plugin, 'edit.php?post_type=offline_products', NULL );
- }
- }
- $start = new CrmErpSolutionProProducts();
File Description
- tewst.php
- PHP Code
- 23 Dec-2020
- 24.87 Kb
You can Share it:
Latest PHP Pastes