Skip to content Skip to sidebar

This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 8:00 – 13:00 9:00 – 13:00 9:00 – 13:00 8:00 – 12:00 8:00 – 12:00 -
- 14:00 – 17:00 14:00 – 18:00 14:00 – 18:00 13:00 – 17:00 13:00 – 17:00 -

Supporter timezone: Europe/Zagreb (GMT+01:00)

Tagged: 

This topic contains 1 replies, has 2 voices.

Last updated by Bruno Kos 1 year, 8 months ago.

Assisted by: Bruno Kos.

Author Posts
April 12, 2024 at 10:30 am #15512511

Stefán Örn Hrafnsson

Hey there I am a developer of a plugin that creates ands syncs products from accounting system. My clients can change the prices of the products in the accounting system but for some reason the prices do not update on your translated product, only the original product. 

here is an broken down code of how i create or update the product i basically receive a json representation of the product from accounts system and create or update the product in woo.

public function create_or_update_product($product) {

$objProductId = wc_get_product_id_by_sku($product->sku);
$objProduct = !empty($objProductId) ? wc_get_product($objProductId) : null;

if(empty($objProduct)){
$objProduct = new WC_Product();
}

/* … buch of code that set up other aspects of the product*/
$objProduct->set_regular_price($product->listPrice);
$objProduct->set_sale_price($sale_price);

if($product->variants){
/* creates variations of the product */
}


 if(!empty($objProduct->get_changes())) {
$this->track_load('product_save');
$objProductId = $objProduct->save();
$this->track_load_end('product_save');
}
/* … buch of code that set up other aspects of the product*/

if($do_update_price) {
$variation->set_regular_price($variation_data['regular_price']);
}
}

here is the code that handles creating the translations

 $translated_product_id = apply_filters( 'wpml_object_id', $objProduct->get_id(), 'product', false, 'en' );

if(empty($translated_product_id)){
do_action( 'wpml_admin_make_post_duplicates', $objProduct->get_id());
$translated_product_id = apply_filters( 'wpml_object_id', $objProduct->get_id(), 'product', false, 'en' );

}

$translated_product = wc_get_product( $translated_product_id );

April 15, 2024 at 10:28 am #15519138

Bruno Kos
WPML Supporter since 12/2018

Languages: English (English ) German (Deutsch ) French (Français )

Timezone: Europe/Zagreb (GMT+01:00)

Can you please try the following:

- Replicate the issue in your sandbox environment. This will allow us to isolate the issue from your production environment.
hidden link

Let me know if possible as our 2nd tier needs more info on how this works.

The topic ‘[Closed] plugin that creates ands syncs products from accounting system’ is closed to new replies.