llms_update_300_migrate_order_data()

Change the post type of orders and rekey meta fields


Return Return

(void)


Top ↑

Source Source

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

function llms_update_300_migrate_order_data() {

	global $wpdb;

	// Prefix the old unprefixed order post type.
	$wpdb->query(
		"UPDATE {$wpdb->posts}
		 SET post_type = 'llms_order'
		 WHERE post_type = 'order';"
	);

	// Rekey postmetas.
	llms_update_util_rekey_meta( 'llms_order', '_llms_payment_gateway', '_llms_payment_method' );
	llms_update_util_rekey_meta( 'llms_order', '_llms_product_id', '_llms_order_product_id' );
	llms_update_util_rekey_meta( 'llms_order', '_llms_currency', '_llms_order_currency' );
	llms_update_util_rekey_meta( 'llms_order', '_llms_coupon_id', '_llms_order_coupon_id' );
	llms_update_util_rekey_meta( 'llms_order', '_llms_coupon_code', '_llms_order_coupon_code' );
	llms_update_util_rekey_meta( 'llms_order', '_llms_coupon_type', '_llms_order_coupon_type' );
	llms_update_util_rekey_meta( 'llms_order', '_llms_coupon_amount', '_llms_order_coupon_amount' );

	llms_update_util_rekey_meta( 'llms_order', '_llms_billing_frequency', '_llms_order_billing_freq' );
	llms_update_util_rekey_meta( 'llms_order', '_llms_billing_length', '_llms_order_billing_cycle' );
	llms_update_util_rekey_meta( 'llms_order', '_llms_billing_period', '_llms_order_billing_period' );

	llms_update_util_rekey_meta( 'llms_order', '_llms_gateway_api_mode', '_llms_stripe_api_mode' );
	llms_update_util_rekey_meta( 'llms_order', '_llms_gateway_subscription_id', '_llms_stripe_subscription_id' );
	llms_update_util_rekey_meta( 'llms_order', '_llms_gateway_customer_id', '_llms_stripe_customer_id' );

	llms_update_util_rekey_meta( 'llms_order', '_llms_trial_total', '_llms_order_first_payment' );

	llms_update_util_rekey_meta( 'llms_order', '_llms_start_date', '_llms_order_date' );

}


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.