You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This filter is used to filter the arguments sent to the remote server during a push. The below code snippet passes the original published date to the new pushed post and sets the same published date instead of setting it as per the current time.
*/
add_filter( 'dt_push_post_args', function( $post_body, $post, $args, $connection ) {
// When pushing to an external connection, we use the REST API, so the name of the field is date.
// But when pushing to an internal connection, the attributes are sent to wp_insert_post, which expects post_date.
$field_prefix =( $connection instanceof \Distributor\ExternalConnections\WordPressExternalConnection ) ? '' : 'post_';
Describe your question
Hello,
i want to change the price of a product whenever it changes on the original, so the copied product will have a percentage of the original.
I tried like this and failed:
`/**
*/
function client_prefix_modify_meta( $post_meta, $existing_meta, $post_id ) {
// Set post meta if not set.
$existing_meta[ '_regular_price'] = '45.55';
$existing_meta[ '_sale_price'] = '34.55';
$existing_meta[ 'post_regular_price'] = '645.55';
$existing_meta[ 'post_sale_price'] = '634.55';
}
add_action( 'dt_after_set_meta', 'client_prefix_modify_meta', 10, 3 );
add_filter( 'dt_push_post_meta', function( $a, $new_post_id, $post_meta, $post_id, $args, $connection ) {
// $field_prefix =( $connection instanceof \Distributor\ExternalConnections\WordPressExternalConnection ) ? '' : 'post_';
},10,6);
/**
Keep the publication date on the new pushed post.
This filter is used to filter the arguments sent to the remote server during a push. The below code snippet passes the original published date to the new pushed post and sets the same published date instead of setting it as per the current time.
*/
add_filter( 'dt_push_post_args', function( $post_body, $post, $args, $connection ) {
// When pushing to an external connection, we use the REST API, so the name of the field is
date
.// But when pushing to an internal connection, the attributes are sent to wp_insert_post, which expects
post_date
.$field_prefix =( $connection instanceof \Distributor\ExternalConnections\WordPressExternalConnection ) ? '' : 'post_';
$post_body[ $field_prefix . 'date'] = $post->post_date;
$post_body[ $field_prefix . 'date_gmt'] = $post->post_date_gmt;
$post_body[ $field_prefix . 'regular_price'] = $post->regular_price-10;
$post_body[ $field_prefix . 'sale_price'] = '3';
$post_body[ $field_prefix . 'description'] = 'chris4';
$post_body[ $field_prefix . 'content'] = "chris4w";
return $post_body;
}, 10, 4 );
`
any help will be appreciated.
Code of Conduct
The text was updated successfully, but these errors were encountered: