Skip to content
Snippets Groups Projects
Select Git revision
  • 1b2a5cc11b30e323917467b8bb070fddc43b741c
  • master default protected
  • bugfix/wordpress-review
  • bugfix/prevent-error-notice
  • remove-arrow
  • feature/update-message
  • feature/minimum-plugin-version-check-demo1
  • feature/plugin-name
  • 3.7.1
  • 3.7.0
  • 3.6.3
  • 3.6.2
  • 3.6.1
  • 3.6.0
  • 3.6.0-beta3
  • 3.6.0-beta2
  • 3.6.0-beta1
  • 3.5.2
  • 3.5.1
  • 3.5.0
  • 3.4.0
  • 3.3.0
  • 3.2.8
  • 3.2.7
  • 3.2.6
  • 3.2.5
  • 3.2.4
  • 3.2.3
28 results

Basic_Requirement_Checker.php

Blame
  • ProductSelectSerializer.php 692 B
    <?php
    
    namespace WPDesk\Forms\Serializer;
    
    use WPDesk\Forms\Serializer;
    
    /**
     * When serializing product select data lets also write product names in keys.
     *
     * @package WPDesk\Forms\Serializer
     */
    class ProductSelectSerializer implements Serializer {
    	public function serialize( $value ) {
    		$products_with_names = [];
    		if ( is_array( $value ) ) {
    			foreach ( $value as $product_id ) {
    				$product = wc_get_product( $product_id );
    				if ( $product ) {
    					$name                         = $product->get_formatted_name();
    					$products_with_names[ $name ] = $product_id;
    				}
    			}
    		}
    
    		return $products_with_names;
    	}
    
    	public function unserialize( $value ) {
    		return $value;
    	}
    
    }