Changeset 3183468
- Timestamp:
- 11/06/2024 11:36:32 PM (17 months ago)
- Location:
- sign-customiser
- Files:
-
- 15 added
- 2 edited
-
tags/1.1.0 (added)
-
tags/1.1.0/.gitignore (added)
-
tags/1.1.0/api.php (added)
-
tags/1.1.0/cart.php (added)
-
tags/1.1.0/config.php (added)
-
tags/1.1.0/orders.php (added)
-
tags/1.1.0/readme.txt (added)
-
tags/1.1.0/settings.php (added)
-
tags/1.1.0/sign-customiser.php (added)
-
trunk/.gitignore (added)
-
trunk/api.php (added)
-
trunk/cart.php (added)
-
trunk/config.php (added)
-
trunk/orders.php (added)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/settings.php (added)
-
trunk/sign-customiser.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
sign-customiser/trunk/readme.txt
r3176486 r3183468 3 3 Tested up to: 6.6.1 4 4 Requires at least: 6.5 5 Stable tag: 1. 0.05 Stable tag: 1.1.0 6 6 Requires PHP: 7.4 7 7 License: GPLv2 or later … … 30 30 == Changelog == 31 31 32 = 1.1.0 = 33 * Added support for syncing orders from Woocommerce to Sign Customiser. 34 32 35 = 1.0 = 33 36 * Initial support for syncing products from an embedded customiser to Woocommerce cart. -
sign-customiser/trunk/sign-customiser.php
r3176486 r3183468 4 4 Plugin Name: Sign Customiser 5 5 Plugin URI: https://signcustomiser.com 6 Version: 1. 0.06 Version: 1.1.0 7 7 Requires Plugins: woocommerce 8 8 License: GPL v2 or later … … 22 22 WP_Filesystem(); 23 23 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 }); 24 require_once 'config.php'; 25 require_once 'api.php'; 26 require_once 'cart.php'; 27 require_once 'settings.php'; 28 require_once 'orders.php';
Note: See TracChangeset
for help on using the changeset viewer.