Skip to content
Snippets Groups Projects
Select Git revision
  • 07b7dda390640ef46eca702c47b71718fddb8ac8
  • master default protected
  • 1.1.0
  • 1.0.2
  • 1.0.1
  • 1.0.0
  • 1.0.0-beta8
  • 1.0.0-beta7
  • 1.0.0-beta6
  • 1.0.0-beta5
  • 1.0.0-beta4
  • 1.0.0-beta3
  • 1.0.0-beta2
  • 1.0.0-beta1
14 results

address-row.jsx

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;
    	}
    
    }