# woocommerce-pos/1.10.13/includes/updates/update-1.6.1.php

WCPOS – Point of Sale (POS) plugin for WooCommerce, version 1.10.13. 102 lines.

- Page: https://pluginprobe.com/plugins/woocommerce-pos/1.10.13/code/includes/updates/update-1.6.1.php
- Raw: https://pluginprobe.com/plugins/woocommerce-pos/1.10.13/raw/includes/updates/update-1.6.1.php
- Modified: 2026-02-06T20:51:24+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/woocommerce-pos/1.10.13/code/includes/updates/update-1.6.1.php#L10-L20`.

```php
<?php
/**
 * Update to 1.6.1
 * Changing POS Only products to use settings rather than postmeta.
 *
 * @package WCPOS\WooCommercePOS
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

/**
 * Change POS Only products to use settings rather than postmeta.
 * NOTE: we will leave the postmeta in place for now, but this will be removed in a future update.
 */
function woocommerce_pos_update_pos_visibility_settings_to_1_6_1() {
	global $wpdb;

	$option_key = 'woocommerce_pos_settings_visibility';

	// Check if the option already exists.
	$visibility_settings = get_option( $option_key );

	if ( false !== $visibility_settings ) {
		// The option already exists, no need to update.
		return;
	}

	// Initialize arrays for product and variation IDs.
	$pos_only_product_ids = array();
	$online_only_product_ids = array();
	$pos_only_variation_ids = array();
	$online_only_variation_ids = array();

	// Query to get all products with _pos_visibility = 'pos_only'.
	$pos_only_product_ids = $wpdb->get_col(
		"
        SELECT post_id
        FROM {$wpdb->postmeta}
        WHERE meta_key = '_pos_visibility' AND meta_value = 'pos_only' AND post_id IN (SELECT ID FROM {$wpdb->posts} WHERE post_type = 'product')
    "
	);

	// Query to get all products with _pos_visibility = 'online_only'.
	$online_only_product_ids = $wpdb->get_col(
		"
        SELECT post_id
        FROM {$wpdb->postmeta}
        WHERE meta_key = '_pos_visibility' AND meta_value = 'online_only' AND post_id IN (SELECT ID FROM {$wpdb->posts} WHERE post_type = 'product')
    "
	);

	// Query to get all variations with _pos_visibility = 'pos_only'.
	$pos_only_variation_ids = $wpdb->get_col(
		"
        SELECT post_id
        FROM {$wpdb->postmeta}
        WHERE meta_key = '_pos_visibility' AND meta_value = 'pos_only' AND post_id IN (SELECT ID FROM {$wpdb->posts} WHERE post_type = 'product_variation')
    "
	);

	// Query to get all variations with _pos_visibility = 'online_only'.
	$online_only_variation_ids = $wpdb->get_col(
		"
        SELECT post_id
        FROM {$wpdb->postmeta}
        WHERE meta_key = '_pos_visibility' AND meta_value = 'online_only' AND post_id IN (SELECT ID FROM {$wpdb->posts} WHERE post_type = 'product_variation')
    "
	);

	// Prepare the new visibility settings.
	$new_visibility_settings = array(
		'products' => array(
			'default' => array(
				'pos_only' => array(
					'ids' => array_map( 'intval', $pos_only_product_ids ),
				),
				'online_only' => array(
					'ids' => array_map( 'intval', $online_only_product_ids ),
				),
			),
		),
		'variations' => array(
			'default' => array(
				'pos_only' => array(
					'ids' => array_map( 'intval', $pos_only_variation_ids ),
				),
				'online_only' => array(
					'ids' => array_map( 'intval', $online_only_variation_ids ),
				),
			),
		),
	);

	// Update the option in the database.
	update_option( $option_key, $new_visibility_settings, false );
}

// Run the update script.
woocommerce_pos_update_pos_visibility_settings_to_1_6_1();

```
