Forum Replies Created

Viewing 8 replies - 1 through 8 (of 8 total)
  • Thread Starter soulvt13

    (@soulvt13)

    Thank you so much.. Really grateful to meet you ! Thank you for the advice.

    Thread Starter soulvt13

    (@soulvt13)

    Hello another question
    This is my sql create table code

    CREATE TABLEwpdt_stockmgmt` (
    ProductID bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT ‘Product ID’,
    ProductCode varchar(50) NOT NULL,
    ProductName varchar(200) NOT NULL,
    Quantity int(11) unsigned NOT NULL DEFAULT ‘0’,
    PRIMARY KEY (ProductID)
    ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8`

    and this is what I added in the functions.php in theme

    function add_custom_field_wpdt_stockmgmt( $elements_options, $shortcode_name, $table ){
      if ( is_null( get_post() ) && 'cdbt-entry' === $shortcode_name && 'wpdt_stockmgmt' === $table ) {
        $elements_options[] = [
          'elementName' => 'ChangeQuantity',
          'elementLabel' => 'Addition/Subtraction',
          'elementType' => 'number',
          'isRequired' => false,
          'defaultValue' => 0,
          'placeholder' => 'Enter changing quantity',
          'addClass' => '',
          'selectableList' => '',
          'horizontalList' => false,
          'elementSize' => 2,
          'helperText' => '',
          'elementExtras' => []
        ];
        $element_order = [0,1,3,2];
        array_multisort( $element_order, $elements_options );
      }
      return $elements_options;
    }
    add_filter( 'cdbt_shortcode_custom_forms', 'add_custom_field_wpdt_stockmgmt', 10, 3);
    
    function custom_update_wpdt_stockmgmt( $data, $table_name, $data_field_format ){
      if ( ! is_admin() && 'wpdt_stockmgmt' === $table_name && isset( $_POST['custom-database-tables']['ChangeQuantity'] ) ) {
        if ( intval( $_POST['custom-database-tables']['ChangeQuantity'] ) !== 0 ) {
          $data['Quantity'] += intval( $_POST['custom-database-tables']['ChangeQuantity'] );
        }
      }
      return $data;
    }

    I can’t update my data using the Addition/Subtraction textbox, need to change manually the quantity. did I do something wrong? Please refers to my site again if you are not bothered. thank you

    Thread Starter soulvt13

    (@soulvt13)

    Thank you so much for your reply. Such an incredible support. Thumbs up! So for the mean time, if i didnt hide the id, it should be okay?

    Thread Starter soulvt13

    (@soulvt13)

    I’m really sorry for the inconvenience.
    I have lowered down the permission to view the data.

    Yeah that’s the problem I described.. My page simply consist of shortcodes from the plugins, sorry for troubling you again, where to check the javascript errors on my page?
    thank you

    Thread Starter soulvt13

    (@soulvt13)

    I mean, for the cbdt edit, if we want to update the record, we ticked one record and clicked update button right? After we clicked update button, a pop out will appear with form of field we want to update. In the demo, after the pop out appear, the field will automatically entered with the details of the record,thus we only need to change the field we wanted to change. In my case, the field all left blank and needed to fill in one by one manually. For troubleshooting purposes, i have opened my website momentarily so you can see the problem. https://stock.andryanvt.xyz/index.php/update-data/

    And can the updated datetime be made automatically registered in the table without appearing in the pop out? ( making a better UI)
    Thankyou, sorry for troubling you

    Thread Starter soulvt13

    (@soulvt13)

    I have been able to add addition and subtraction, but when I clicked to update the data, the textbox didn’t automatically updated to the field. any solution??

    Thread Starter soulvt13

    (@soulvt13)

    sorry to bother you..
    if we create table named stockmgmt, should we change the filter hooks to function add_custom_field_wpdt_stockmgmt …. and all wp_products to wpdt_stockmgmt or leave it be wp_products?

    and we should add above code in the functions.php from the theme right?

    Thread Starter soulvt13

    (@soulvt13)

    Sorry if this sound silly, i should add the filter hooks in function.php right? Thanks

    I’m new to wordpress

Viewing 8 replies - 1 through 8 (of 8 total)