Plugin Directory

Changeset 3183468


Ignore:
Timestamp:
11/06/2024 11:36:32 PM (17 months ago)
Author:
signcustomiser
Message:

Release version 1.1.0

Location:
sign-customiser
Files:
15 added
2 edited

Legend:

Unmodified
Added
Removed
  • sign-customiser/trunk/readme.txt

    r3176486 r3183468  
    33Tested up to: 6.6.1
    44Requires at least: 6.5
    5 Stable tag: 1.0.0
     5Stable tag: 1.1.0
    66Requires PHP: 7.4
    77License: GPLv2 or later
     
    3030== Changelog ==
    3131
     32= 1.1.0 =
     33* Added support for syncing orders from Woocommerce to Sign Customiser.
     34
    3235= 1.0 =
    3336* Initial support for syncing products from an embedded customiser to Woocommerce cart.
  • sign-customiser/trunk/sign-customiser.php

    r3176486 r3183468  
    44Plugin Name: Sign Customiser
    55Plugin URI: https://signcustomiser.com
    6 Version: 1.0.0
     6Version: 1.1.0
    77Requires Plugins: woocommerce
    88License: GPL v2 or later
     
    2222WP_Filesystem();
    2323
    24 function spcwp_product_callback($request) {
    25   $data = $request['product'];
    26 
    27   $product = new WC_Product();
    28 
    29   $product->set_name(wc_trim_string($data['text'], 20));
    30   $product->set_price(floatval($data['price']));
    31   $product->set_regular_price(floatval($data['price']));
    32   $product->set_description($data['description']);
    33 
    34   if (!empty($data['productImage'])) {
    35     $upload_dir = wp_upload_dir();
    36     $image_data = base64_decode($data['productImage']);
    37     $filename = $upload_dir['path'] . '/sign-customiser/' . uniqid() . '.png';
    38     $fs = new WP_Filesystem_Direct( true );
    39     $fs->put_contents($filename, $image_data);
    40 
    41     $filetype = wp_check_filetype(basename($filename), null);
    42     $attachment = [
    43       'post_mime_type' => $filetype['type'],
    44       'post_title' => preg_replace('/\.[^.]+$/', '', basename($filename)),
    45       'post_content' => '',
    46       'post_status' => 'inherit',
    47     ];
    48     $attach_id = wp_insert_attachment($attachment, $filename);
    49 
    50     $product->set_image_id($attach_id);
    51   }
    52 
    53   $id = $product->save();
    54 
    55   wp_set_object_terms($id, 'SignCustomiser', 'product_tag');
    56 
    57   return rest_ensure_response(['product_id' => $id]);
    58 }
    59 
    60 add_action('rest_api_init', function () {
    61   register_rest_route('spc', '/products', [
    62     'methods' => WP_REST_Server::CREATABLE,
    63     'callback' => 'spcwp_product_callback',
    64   ]);
    65 });
     24require_once 'config.php';
     25require_once 'api.php';
     26require_once 'cart.php';
     27require_once 'settings.php';
     28require_once 'orders.php';
Note: See TracChangeset for help on using the changeset viewer.