Tuesday, May 16, 2023

Notification to any email address with add to cart woocommerce

 add_action( 'woocommerce_add_to_cart', 'cwpai_woo_send_email_to_admin_on_add_to_cart', 10, 6 );

function cwpai_woo_send_email_to_admin_on_add_to_cart( $cart_item_key, $product_id, $quantity, $variation_id, $variation, $cart_item_data ) {

  

    $product      = wc_get_product( $product_id );

    $product_name = $product->get_name();

    if ( isset( $_POST['add-to-cart']) ) {

    $company_name =  $_POST['membership_company_name'];

    $contact_person =  $_POST['membership_contact_person'];

    $membership_address =  $_POST['membership_address'];

    $membership_city_town =  $_POST['membership_city_town'];

    $province =  $_POST['province'];

    $postal_code =  $_POST['postal_code'];

    $wcb =  $_POST['wcb'];

    $industry_code_s =  $_POST['industry_code_s'];

    $cor =  $_POST['cor'];

    $expiry_date =  $_POST['expiry_date'];

    $if_your =  $_POST['if_your'];

    }

$data = "<table style='width:50%' cellpadding='5'><tr>

   <th>Item</th>

   <th>Description</th>

   </tr><tr>

   <td>Name</td>

   <td>$product_name</td>

   </tr>

   <tr>

   <td>Company Name:</td>

   <td>$company_name</td>

   </tr>

   <tr>

   <td>Address</td>

   <td>$membership_address</td>

   </tr>

   <tr>

   <td>City/Town</td>

   <td>$membership_city_town</td>

   </tr>

   <tr>

   <td>Province</td>

   <td>$province</td>

   </tr>

   <tr>

   <td>Postal Code</td>

   <td>$postal_code</td>

   </tr>

   <tr>

   <td>WCB #</td>

   <td>$wcb</td>

   </tr>

   <tr>

   <td>Industry Code(s)</td>

   <td>$industry_code_s</td>

   </tr>

   <tr>

   <td>C.O.R #</td>

   <td>$cor</td>

   </tr>

   <tr>

   <td>Expiry Date</td>

    <td>$expiry_date</td>

   </tr>

   <tr>

    <td>If your company has ever registered with another Certifying Partner please name</td>

    <td>$if_your</td>

    </tr></table>";


$headers = array('Content-Type: text/html; charset=UTF-8');

    wp_mail( 'example@gmail.com', 'New notification', $data, $headers );

 

}


Wednesday, May 3, 2023

Access to all membership facilities to Admin

 Pro Membership


 

   function pmmpro_allow_access_for_admins($hasaccess, $mypost, $myuser,       $post_membership_levels){
  
  //If user is an admin allow access.
if( current_user_can( 'manage_options' ) ){
$hasaccess = true;

return $hasaccess;
}
add_filter('pmpro_has_membership_access_filter', 'pmmpro_allow_access_for_admins', 30, 4); 

For Professional website contact WEB CODE ADDICT

View this post on Instagram A post shared by WebCodeAddict (@webcodeaddicted)