llms_update_300_migrate_coupon_data()

Move coupon title (previously used for description) to the postmeta table in the new description field Move old coupon code from meta table to the coupon post title *


Description Description


Source Source

File: includes/functions/llms.functions.updates.php

function llms_update_300_migrate_coupon_data() {

	global $wpdb;

	$coupon_title_metas = $wpdb->get_results(
		"SELECT * FROM {$wpdb->postmeta}
		 WHERE meta_key = '_llms_coupon_title';"
	);

	foreach ( $coupon_title_metas as $obj ) {

		// update new description field with the title b/c the title previously acted as a description
		update_post_meta( $obj->post_id, '_llms_description', get_the_title( $obj->post_id ) );

		// update the post title to be the value of the old meta field
		wp_update_post( array(
			'ID' => $obj->post_id,
			'post_title' => $obj->meta_value,
		) );

		// clean up
		delete_post_meta( $obj->post_id, '_llms_coupon_title' );

	}

}

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.