• Resolved turnerdyr

    (@turnerdyr)


    Hello, it’s possible to insert rules from mySQL in wp_wdp_rules?

    Actually works, but throw some warnings like

    Warning: reset() expects parameter 1 to be array,
    Parameter must be an array or an object that implements Countable and
    Invalid argument supplied for foreach

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hi, turnerdyr,

    Can you describe in more detail what you want to do and how you do it?

    Thread Starter turnerdyr

    (@turnerdyr)

    Hello, what I did was simplify the interface because it is not entirely friendly and I only need a few options. So what I did was copy the sql queries from the database (wdp_rules) and insert them again with the corresponding modifications.

    For example a random sql bulk

    INSERT INTO wp_wdp_rules(deleted, enabled, exclusive, type, title, priority, options, additional, conditions, filters, limits, product_adjustments, sortable_blocks_priority, bulk_adjustments, role_discounts, cart_adjustments, get_products) VALUES (0, 1, 0, ‘package’, ‘test’, 0, ‘a:2:{s:6:\”repeat\”;s:2:\”-1\”;s:8:\”apply_to\”;s:9:\”expensive\”;}’, ‘a:4:{s:12:\”replace_name\”;s:0:\”\”;s:19:\”sortable_apply_mode\”;s:12:\”consistently\”;s:26:\”free_products_replace_name\”;s:0:\”\”;s:23:\”conditions_relationship\”;s:3:\”and\”;}’, ‘a:0:{}’, ‘a:0:{}’, ‘a:0:{}’, ‘a:2:{s:5:\”total\”;a:2:{s:4:\”type\”;s:16:\”discount__amount\”;s:5:\”value\”;s:0:\”\”;}s:16:\”max_discount_sum\”;s:0:\”\”;}’, ‘a:2:{i:0;s:5:\”roles\”;i:1;s:16:\”bulk-adjustments\”;}’, ‘a:2:{s:4:\”type\”;s:4:\”bulk\”;s:13:\”table_message\”;s:0:\”\”;}’, ‘a:0:{}’, ‘a:0:{}’, ‘a:2:{s:6:\”repeat\”;s:2:\”-1\”;s:15:\”repeat_subtotal\”;s:0:\”\”;}’);

    my sql query:

    $deleted = 0;
    $enabled = 1;
    $exclusive = 0;
    $type = ‘package’;
    $title = $nombredelapromocion;
    $priority = $prioridad;
    $options = ‘a:2:{s:6:”repeat”;s:2:”-1″;s:8:”apply_to”;s:9:”expensive”;}’;
    $additional = ‘a:4:{s:12:”replace_name”;s:0:””;s:19:”sortable_apply_mode”;s:12:”consistently”;s:26:”free_products_replace_name”;s:0:””;s:23:”conditions_relationship”;s:3:”and”;}’;
    $conditions = ‘a:0:{}’;
    $filters = ‘a:1:{i:0;a:5:{s:3:”qty”;s:1:”1″;s:4:”type”;s:8:”products”;s:10:”limitation”;s:4:”none”;s:6:”method”;s:7:”in_list”;s:5:”value”;a:1:{i:0;s:4:”‘.$idproducto.'”;}}}’;
    $limits = ‘a:0:{}’;
    $product_adjustments = ‘a:3:{s:5:”total”;a:2:{s:4:”type”;s:16:”discount__amount”;s:5:”value”;s:0:””;}s:5:”split”;a:1:{i:0;a:2:{s:4:”type”;s:16:”discount__amount”;s:5:”value”;s:0:””;}}s:16:”max_discount_sum”;s:0:””;}’;
    $sortable_blocks_priority = ‘a:2:{i:0;s:5:”roles”;i:1;s:16:”bulk-adjustments”;}’;
    $bulk_adjustments = ‘a:5:{s:4:”type”;s:4:”bulk”;s:9:”qty_based”;s:3:”all”;s:13:”discount_type”;s:20:”discount__percentage”;s:6:”ranges”;a:1:{i:0;a:3:{s:4:”from”;s:1:”‘.$cantidadminimadelapromocion.'”;s:2:”to”;s:5:”10000″;s:5:”value”;s:2:”‘.$descuentodelapromocion.'”;}}s:13:”table_message”;s:0:””;}’;
    $role_discounts = ‘a:0:{}’;
    $cart_adjustments = ‘a:0:{}’;
    $get_products = ‘a:2:{s:6:”repeat”;s:2:”-1″;s:15:”repeat_subtotal”;s:0:””;}’;

    $sql = “INSERT INTO wp_wdp_rules(deleted, enabled, exclusive, type, title, priority, options, additional, conditions, filters, limits, product_adjustments, sortable_blocks_priority, bulk_adjustments, role_discounts, cart_adjustments, get_products) VALUES ($deleted, $enabled, $exclusive, ‘$type’, ‘$title’, $priority, ‘$options’, ‘$additional’, ‘$conditions’, ‘$filters’, ‘$limits’, ‘$product_adjustments’, ‘$sortable_blocks_priority’, ‘$bulk_adjustments’, ‘$role_discounts’, ‘$cart_adjustments’, ‘$get_products’)”;
    mysqli_query($conn,$sql);

    With this I get the same query but for some reason it doesn’t work

    Thread Starter turnerdyr

    (@turnerdyr)

    i think i figured out, in bulk adjusment:

    a:2:{i:0;s:5:”roles”;i:1;s:16:”bulk-adjustments”;}’;
    $bulk_adjustments = ‘a:5:{s:4:”type”;s:4:”bulk”;s:9:”qty_based”;s:3:”all”;s:13:”discount_type”;s:20:”discount__percentage”;s:6:”ranges”;a:1:{i:0;a:3:{s:4:”from”;s:1:”‘.$cantidadminimadelapromocion.'”;s:2:”to”;s:5:”10000″;s:5:”value”;s:2:”‘.$descuentodelapromocion.'”;}}s:13:”table_message”;s:0:””;}

    s:1 it’s not working but if i change for s:2 it does. ?why??this number changes?

    Thread Starter turnerdyr

    (@turnerdyr)

    Yes, i figured out.

    from s:1 is the str len of minium qty
    s:5 the same str len of maximum qty
    s:2 str len of %

    (You have to modify that parameters in the sql query too)
    Thanks.

    • This reply was modified 4 years, 3 months ago by turnerdyr.
    Plugin Author algol.plus

    (@algolplus)

    Hello

    You should use PHP function serialize

    open file /BaseVersion/Includes/Common/Datavase.php and review ajax_save_rule()

    thanks, Alex

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Rules from database’ is closed to new replies.