PluginUs.Net - Business Tools for WooCommerce and WordPress

[realize your idea - make your dreams come true]

Support Forum

You need to log-in to create request (topic) to the support

Hook woobe_after_update_page_field seems not working

The support doesn work on Saturdays and Sundays, so some Friday requests can be answered on Monday. If you have problems with registration ask help on contact us page please
If you not got email within 24~36 business hours, firstly check your spam box, and if no any email from the support there - back to the forum and read answer here. DO NOT ANSWER ON EMAILS [noreply@pluginus.net] FROM THE FORUM!! Emails are just for your info, all answers should be published only here.
The support doesn work on Saturdays and Sundays, so some Friday requests can be answered on Monday.

Hi, working on a custom extension to trigger a function after regular price change (for simple and variable products).

When trying to add extends class a WOOBE_EXT getting error: Class"WOOBE_EXT" not found.

Hello

So you are trying to use this class when it is not included

Unfortunately, that's all I can assume with this information.

 

Ok, thank you for prompt reply

Trying to add class and use, but didn't help.

I actually need to call a function outside of BEAR (in a custom plugin) and wanted to use action woobe_after_update_page_field for this purpose. Here is the plugin

 

<?php

//include WP_PLUGIN_DIR . '/woo-bulk-editor/classes/ext.php';

# Check if class exist

if (!class_exists('MRKV_KEYCRM_PRODUCT_WOOBE'))

{

/**

* Class for setup woobe products settings

*/

final class MRKV_KEYCRM_PRODUCT_WOOBE extends WOOBE_EXT

{

/**

* @var string Code type

* */

protected $is = 'external';




/**

* Constructor Woobe

* */

public function __construct() 

{

# Add action to woobe updated

        add_action('woobe_after_update_page_field', array($this, 'mrkv_kcrm_prod_on_woobe_save'), 1);

}




/**

* Action after woobe save

* @var integer Product ID

* @param object Product

* @var string Field key

* @var mixed New value

* @var string Value type

* */

public function mrkv_kcrm_prod_on_woobe_save($product_id, $product, $field_key, $value, $field_type)

{

$script_start_text ="field_key:" . print_r($field_key, 1) ."\r\n";

# Write text to degug.log file

file_put_contents( __DIR__ . '/debug.log', $script_start_text, FILE_APPEND );




if($field_key == 'regular_price')

{

# Create params

$params = array(

'offers' => array(

array(

'sku' => $product->get_sku(),

'price' => $value,

),

)

);




# Send request

$this->mrkv_keycrm_send_product($params);

}

if($field_key == 'mrkv_product_cost')

{

if ( $product->is_type( 'variable' ) )

{

# Get all variations

$variations = $product->get_children();




$params = array();




foreach($variations as $variation_id)

{

$variation_obj = wc_get_product($variation_id);




if($variation_obj && $variation_obj->get_sku())

{

$params['offers'][] = array(

'sku' => $variation_obj->get_sku(),

'purchased_price' => $value

);

}

}




# Send request

$this->mrkv_keycrm_send_product($params);

}

else

{

# Create params

$params = array(

'offers' => array(

array(

'sku' => $product->get_sku(),

'purchased_price' => $value,

),

)

);




# Send request

$this->mrkv_keycrm_send_product($params);

}

}

}




/**

* Send request

* @param array Params

* @var string Product ID

* */

private function mrkv_keycrm_send_product($params)

{

# Include Api KEYCRM

        require_once(KEYCRM_PRODUCT_PLUGIN_PATH . '/classes/api/class-mrkv-keycrm-product-api.php');




        # Create api object

        $keycrm_api = new MRKV_KEYCRM_PRODUCT_API();




        # Send request

        $result = $keycrm_api->mrkv_keycrm_prod_api_send_product($params);

}

}

}

Hello

When connecting your custom plugin (with this implementation), you need to monitor the plugin connection queue. And connect your class only after connecting my plugin

And in principle, I don’t see any reason why you would extend your class from WOOBE_EXT You can just use the hook - woobe_after_update_page_field

Thanks, worked!

Hello

Great! welcome;)