Question: I am running a simple form input on my localhost:port using socket programming.

Currently, I have a form running on my chrome, just a text box on localhost:2333, I am able to see the text box input on my wireshark like this
[![enter image description here](https://i.stack.imgur.com/PHtgC.png)](https://i.stack.imgur.com/PHtgC.png)

The input message I typed is testesest.
After which, I put the `<form action="http://localhost:2333">` such that the entered form data can flow back to my `localhost:port`. However, my 2nd `r= recv(1024)`is not receiving anything.

```
import socket
import sys
import os

Addr = ''
PORT = 2333
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind((Addr, PORT))
s.listen()

```

The above is the standard part.

```
while(1):
    try:
        print("waiting for connection")
        conn, address = s.accept()
        print("New client connected from IP address {} and port number {}".format(*address))

        received = conn.recv(1024)
        #print("Request received")

        #This is what i am hosting
        #A webpage with a form

        conn.send(b'\r\n')

        #This is the webpage content

        #The code will stuck here at recv
        print("Waiting for form input from client")
        r = conn.recv(1024)
        print(r.decode())

        print("Form input received")
        print("HTTP response sent")

    except KeyboardInterrupt:
        conn.close()
        s.close()

    conn.close()
    s.close()
    break   

```

Can I get some help please?

Answer: 
You can check product type on the `WC_Product` object for **simple subscription** like:

```
if( $product->get_type() === 'subscription' ) {
    // Do something
}

```

or

```
if( $product->is_type('subscription') ) {
    // Do something
}

```

And here below is an example usage that will avoid access to simple subscription product pages, redirecting customer to main shop page and displaying an error notice:

```
add_action('template_redirect', 'conditional_single_product_page_access');
function conditional_single_product_page_access(){
    // Targeting single product pages
    if ( is_product() ) {
        $product = wc_get_product( get_the_ID() ); // Get the WC_Product Object

        // Targeting simple subscription products
        if( $product->get_type() === 'subscription' ) {
            wc_add_notice( __("You are not allowed to access this product"), 'error' ); // Notice
            wp_safe_redirect( get_permalink( wc_get_page_id( 'shop' ) ) ); // Redirection
            exit();
        }
    }
}

```

Code goes in functions.php file of the active child theme (or active theme). Tested and works.

---

**Notes:**

* To target **variable subscription** product type use the slug `variable-subscription`.
* To target a **variation subscription**, the product type slug is: `subscription_variation`.
You can use `is_subscription()` of `WC_Subscriptions_Product`. You need to pass `$product` object in is\_subscription() function as parameter. Check the below code.

```
if( WC_Subscriptions_Product::is_subscription( $product ) ) {
    // product is subscription.
} else {
    // product is not subscription.
}

```

**Update**

Use `woocommerce_product_is_visible` filter hook for remove the product from product catalog. check below code.

```
add_filter( 'woocommerce_product_is_visible', 'hide_product_if_is_subscription', 20, 2 );
function hide_product_if_is_subscription( $is_visible, $product_id ){
    if( WC_Subscriptions_Product::is_subscription( $product_id ) ) {    
        $is_visible = false;
    }
    return $is_visible;
}

```