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 *


Return Return

(void)


Top ↑

Source Source

File: includes/functions/updates/llms-functions-updates-300.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 ↑

Changelog Changelog

Changelog
Version Description
3.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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